Skip to content

Instantly share code, notes, and snippets.

@aarti
Created September 26, 2014 18:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aarti/4609b31cea4a7edae236 to your computer and use it in GitHub Desktop.
Save aarti/4609b31cea4a7edae236 to your computer and use it in GitHub Desktop.
Ruby lang hash resize algorithim
new_size(st_index_t size)
{
st_index_t i;
for (i=3; i<31; i++) {
if ((st_index_t)(1<<i) > size) return 1<<i;
}
#ifndef NOT_RUBY
rb_raise(rb_eRuntimeError, "st_table too big");
#endif
return -1; /* should raise exception */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment