DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
High-performance Ruby: Faster Symbol.to_s
Here's something that I found useful for shaving a few microseconds off. The performance gain ranges between 10% and 35%! YMMV. Note: updated with suggestion by trans.
class Symbol def to_s @str_rep || (@str_rep = id2name.freeze) end end