A blog article on performant vs idiomatic code (using Crystal examples)

The code for generating the representation seems excessively complex in all variations.
I think it can be shortened to just two branches.
This is the example for the last implementation, but the equivalent applies to the others as well:

if count >= 4 || c == '{'
  into << '{' << c << count << '}'
  count.times { into << c }
1 Like