This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* hash.c */ | |
| static int | |
| rb_strhash_hash_cmp(VALUE a, VALUE b) | |
| { | |
| #ifdef RUBY18 | |
| VALUE args[2]; | |
| #endif | |
| if (a == b) return 0; | |
| if (FIXNUM_P(a) && FIXNUM_P(b)) return a != b; | |
| if (a == Qundef || b == Qundef) return -1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static int | |
| strhash(register const char *string) | |
| { | |
| register int c; | |
| register int val = 0; | |
| while ((c = *string++) != '\0') { | |
| val = val*997 + c; | |
| } | |
| return val + (val>>5); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct RHash { | |
| struct RBasic basic; | |
| struct st_table *tbl; | |
| int iter_lev; | |
| VALUE ifnone; | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static struct st_hash_type objhash = { | |
| rb_any_cmp, | |
| rb_any_hash, | |
| }; | |
| static VALUE | |
| hash_alloc(klass) | |
| VALUE klass; | |
| { | |
| VALUE hash = hash_alloc0(klass); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static int | |
| rb_any_hash(a) | |
| VALUE a; | |
| { | |
| VALUE hval; | |
| switch (TYPE(a)) { | |
| case T_FIXNUM: | |
| case T_SYMBOL: | |
| return (int)a; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static int | |
| rb_any_cmp(a, b) | |
| VALUE a, b; | |
| { | |
| VALUE args[2]; | |
| if (a == b) return 0; | |
| if (FIXNUM_P(a) && FIXNUM_P(b)) { | |
| return a != b; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static VALUE | |
| flo_to_s(flt) | |
| VALUE flt; | |
| { | |
| char buf[32]; | |
| double value = RFLOAT(flt)->value; | |
| char *p, *e; | |
| if (isinf(value)) | |
| return rb_str_new2(value < 0 ? "-Infinity" : "Infinity"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/activesupport/lib/active_support/core_ext/hash.rb b/activesupport/lib/active_support/core_ext/hash.rb | |
| index 5014834..591363d 100644 | |
| --- a/activesupport/lib/active_support/core_ext/hash.rb | |
| +++ b/activesupport/lib/active_support/core_ext/hash.rb | |
| @@ -6,3 +6,5 @@ require 'active_support/core_ext/hash/indifferent_access' | |
| require 'active_support/core_ext/hash/keys' | |
| require 'active_support/core_ext/hash/reverse_merge' | |
| require 'active_support/core_ext/hash/slice' | |
| + | |
| +require 'hwia_rails' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| methodmissing:hwia lourens$ rake bench | |
| (in /Users/lourens/projects/hwia) | |
| /opt/local/bin/ruby bench/bench.rb | |
| Rehearsal ------------------------------------------------------------------------------ | |
| StrHash#[:sym] 0.000000 0.000000 0.000000 ( 0.002949) | |
| HashWithIndifferentAccess#[:sym] 0.020000 0.000000 0.020000 ( 0.021825) | |
| StrHash#['str'] 0.010000 0.000000 0.010000 ( 0.012166) | |
| HashWithIndifferentAccess#['str] 0.000000 0.000000 0.000000 ( 0.003780) | |
| StrHash#key?(:sym) 0.010000 0.000000 0.010000 ( 0.002945) | |
| HashWithIndifferentAccess#key?(:sym) 0.010000 0.000000 0.010000 ( 0.013988) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| methodmissing:activesupport lourens$ git diff | |
| diff --git a/activesupport/lib/active_support/core_ext/hash.rb b/activesupport/lib/active_support/core_ext/hash.rb | |
| index 5014834..591363d 100644 | |
| --- a/activesupport/lib/active_support/core_ext/hash.rb | |
| +++ b/activesupport/lib/active_support/core_ext/hash.rb | |
| @@ -6,3 +6,5 @@ require 'active_support/core_ext/hash/indifferent_access' | |
| require 'active_support/core_ext/hash/keys' | |
| require 'active_support/core_ext/hash/reverse_merge' | |
| require 'active_support/core_ext/hash/slice' | |
| + |