Hacker News new | ask | show | jobs
by progval 1265 days ago
Symbols can even improve performance. Replace them with integers at compile time like a global enum, and so the runtime only needs to compare integers instead of potentially lengthy (especially if UTF-16) strings.
1 comments

> Replace them with integers at compile time like a global enum, and so the runtime only needs to compare integers instead of potentially lengthy (especially if UTF-16) strings.

All of those strings will be interned, and can thus be compared by identity. Which is an integer comparison.