diff options
author | 卜部昌平 <shyouhei@ruby-lang.org> | 2021-05-07 12:49:32 +0900 |
---|---|---|
committer | 卜部昌平 <shyouhei@ruby-lang.org> | 2021-05-12 10:30:46 +0900 |
commit | cc0dc67bbbe1951ff90004bc987f78545625d772 (patch) | |
tree | b6bf1c68d335875409ecd96bf56ef6e5dec64f92 /complex.c | |
parent | d0e6c6e682b9ba2b0309a5177933a0628e8ef316 (diff) | |
download | ruby-cc0dc67bbbe1951ff90004bc987f78545625d772.tar.gz |
cdhash_cmp: can also take complex
There are complex literals `123i`, which can also be a case condition.
Diffstat (limited to 'complex.c')
-rw-r--r-- | complex.c | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -1326,8 +1326,8 @@ nucomp_numerator(VALUE self) } /* :nodoc: */ -static VALUE -nucomp_hash(VALUE self) +st_index_t +rb_complex_hash(VALUE self) { st_index_t v, h[2]; VALUE n; @@ -1338,7 +1338,13 @@ nucomp_hash(VALUE self) n = rb_hash(dat->imag); h[1] = NUM2LONG(n); v = rb_memhash(h, sizeof(h)); - return ST2FIX(v); + return v; +} + +static VALUE +nucomp_hash(VALUE self) +{ + return ST2FIX(rb_complex_hash(self)); } /* :nodoc: */ |