3 ms·
Man, lately I've been amazed by how many performance tricks like these are just bog standard APL. For example, string interning looks like this: strs←∪inpu
by xelxebar 2y ago
Man, lately I've been amazed by how many performance tricks like these are just bog standard APL. For example, string interning looks like this:
strs←∪input_strings ⍝ Build
strs⍪←⊂'new string' ⍝ Append
strs⍳⊂'some string' ⍝ Search
f←strs∘⍳ ⍝ Hash table creation
One extra advantage on top of standard interning is that this also uses an incarnation of tiny pointers[0], automatically saving 2X memory generally. Better yet, standard APL data design will often obviate the need for most string searches, letting you get away with integer comparisons instead.
I'm starting to really see how data-oriented design tends to make straightforward code both parsimonious and highly performant.
[0]:https://news.ycombinator.com/item?id=43023634 https://news.ycombinator.com/item?id=43023634