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

**URL:** <https://forum.crystal-lang.org/t/a-blog-article-on-performant-vs-idiomatic-code-using-crystal-examples/6267>\
**Category:** News\
**Tags:** blog\
**Created:** [January 6, 2024, 8:57pm UTC](https://forum.crystal-lang.org/t/a-blog-article-on-performant-vs-idiomatic-code-using-crystal-examples/6267 "2024-01-06T20:57:57Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![straight-shoota](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/straight-shoota/32/36_2.png) [@straight-shoota](https://forum.crystal-lang.org/u/straight-shoota)\
**Post date:** [January 6, 2024, 10:59pm UTC](https://forum.crystal-lang.org/t/a-blog-article-on-performant-vs-idiomatic-code-using-crystal-examples/6267/3 "2024-01-06T22:59:57Z")

</div>

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:

```crystal
if count >= 4 || c == '{'
  into << '{' << c << count << '}'
else
  count.times { into << c }
end

```

---

_[View the full topic](https://forum.crystal-lang.org/t/a-blog-article-on-performant-vs-idiomatic-code-using-crystal-examples/6267)._
