You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
and then stored the names in a static global lookup table (which was just a vec<String>). I made no effort to de-duplicate the strings, or clean up strings once they are no longer being used. I only hacked enough to make the rewrite-tests pass, but they seemed to be about twice as quick.
It's of course possible I horribly messed things up, but I think this is such a frequently used enum it's probably worth opimising like this. If we did de-duplicate the names (which wouldn't be that hard, store for example a vec<String> for the names, and a HashMap<String, u32> to go from Strings back to indices in the Vec, then always give out the same int)`, then equality of strings becomes equality of the int)
At this point it might not be worth the work for a 2x speedup, but one reason to think about it is right now it's probably not too much work (mainly adding some accessors and a constructor to Name is 95% of the work).
I'm happy to advise, or even share my horrible code, but my code is definately not suitable for merging! (I chucked an unsafe in just to make Rust stop complaining, which wasn't required :) )
The text was updated successfully, but these errors were encountered:
I had a quick run of a profiler to see where time was being spent, and about half the time was spent copying String in UserName in Name.
The
Name
enum looks like:I quickly hacked this to:
and then stored the names in a static global lookup table (which was just a
vec<String>
). I made no effort to de-duplicate the strings, or clean up strings once they are no longer being used. I only hacked enough to make the rewrite-tests pass, but they seemed to be about twice as quick.It's of course possible I horribly messed things up, but I think this is such a frequently used enum it's probably worth opimising like this. If we did de-duplicate the names (which wouldn't be that hard, store for example a
vec<String>
for the names, and aHashMap<String, u32>
to go from Strings back to indices in the Vec, then always give out the same int)`, then equality of strings becomes equality of the int)At this point it might not be worth the work for a 2x speedup, but one reason to think about it is right now it's probably not too much work (mainly adding some accessors and a constructor to
Name
is 95% of the work).I'm happy to advise, or even share my horrible code, but my code is definately not suitable for merging! (I chucked an
unsafe
in just to make Rust stop complaining, which wasn't required :) )The text was updated successfully, but these errors were encountered: