Project

General

Profile

« Previous | Next » 

Revision 442b77e7

Added by normal over 8 years ago

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
  • common.mk: hash.o depends on symbol.h
    Thanks to Bruno Escherl for the bug report
    [ruby-core:70129] [Bug #11396]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51410 b2dd03c8-39d4-4d8f-98ff-823fe69b080e