3 ms·
I've used these when I've had some code with thousands of strings. I concatenated them with the ASCII separators in the source code, then called String.split as
by theandrewbailey 2y ago
I've used these when I've had some code with thousands of strings. I concatenated them with the ASCII separators in the source code, then called String.split as needed. The speedup was noticeable, probably since the runtime choked on instantiating so many strings at one time when launched.
- Jerrrrrrry 2y agoStringBuilder in both JS and .Net has a class especially for this.
- foxglacier 2y agoThat's for concatenating. He's splitting.
- Jerrrrrrry 2y agoSplitting, even if it's not re-concatenated (unlikely in practice) would still benefit from the cache-optimization/ lack of garbage collection overhead / consequential bytes in literal RAM, no?
- foxglacier 2y agoYea sounds bizarre but he observed that.
- theandrewbailey 2y agoI dug up where I used it. It was a bible in HTML and JS. At first, it was using arrays of arrays of strings (for chapters and verses), but I refactored it to really long strings for each book with those separators. The entire bible is one JSON object in the source, keyed by book and the values are those really long strings. https://raw.githubusercontent.com/theandrewbailey/OfflineBible/refs/heads/gh-pages/KJV.html https://raw.githubusercontent.com/theandrewbailey/OfflineBib... A StringBuilder wouldn't work, since there's nothing left to concatenate.
- foxglacier 2y agoBut really you could have used any other character that wasn't going to appear in your strings, especially a visible one like “␟” U+241F "Symbol For Unit Separator".
- Jerrrrrrry 2y agoi actually used [U+263A] and [U+263B] for this purpose, ignorantly (in good faith)...in pro/gov/civ projects....not realizing the canonized name wasn't "Smiley/Inverted Smiley" at the time, which may have been an oversight. Ironically, I looked for that very control character, and I think it may not had worked with Excel/Clipboard, so was a no-go for biz ops. I never understood how people were able to abbreviate the U S into ␟ without triggering the USA flag, like on youtube. After reading historical/proposed Unicode RFC's, having scrolled past every glyph that could combine into graphene clusters and fuzzed unicode input on many systems.... today I am humbled to learn that ␟ is not nor US, but the exact unit by which its own proliferation would itself de-nomen-ize itself.