path: root/symbol.h
diff options
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-07-27 22:25:30 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-07-27 22:25:30 +0000
commit442b77e72166c9c993e3c6663568431123510dec (patch)
treec26e34c8555b9568067c5fcf029d65856ca7c7ae /symbol.h
parentdc9ca079bbd37e9e6ab5caed48a665aa616aa2a1 (diff)
symbol.h: memoize hashval for RSymbol
This speeds up the hash function for dynamic symbols. [ruby-core:70129] [Bug #11396], nearly up to Ruby 2.1 levels Power-of-two hash sizing [Feature #9425] speeds up cases where we have a good hash, but this means we can no longer hide behind weak hashes. Unfortunately, object IDs do not hash well, but we may use the extra space in the RSymbol struct to memoize the hash value. Further optimizations should be possible. For now, the st.c APIs force us to calculate rb_str_hash redundantly at dsym registration. * symbol.h (struct RSymbol): add hashval field * symbol.c (dsymbol_alloc): setup hashval field once * hash.c (rb_any_hash): return RSymbol->hashval directly * hash.o depends on symbol.h Thanks to Bruno Escherl <> for the bug report [ruby-core:70129] [Bug #11396] git-svn-id: svn+ssh:// b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'symbol.h')
1 files changed, 1 insertions, 0 deletions
diff --git a/symbol.h b/symbol.h
index 549eabdf610..5c52b9742b6 100644
--- a/symbol.h
+++ b/symbol.h
@@ -25,6 +25,7 @@
struct RSymbol {
struct RBasic basic;
+ st_index_t hashval;
VALUE fstr;
ID id;