aboutsummaryrefslogtreecommitdiffstats
path: root/complex.c
diff options
context:
space:
mode:
author卜部昌平 <shyouhei@ruby-lang.org>2021-05-07 12:49:32 +0900
committer卜部昌平 <shyouhei@ruby-lang.org>2021-05-12 10:30:46 +0900
commitcc0dc67bbbe1951ff90004bc987f78545625d772 (patch)
treeb6bf1c68d335875409ecd96bf56ef6e5dec64f92 /complex.c
parentd0e6c6e682b9ba2b0309a5177933a0628e8ef316 (diff)
downloadruby-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.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/complex.c b/complex.c
index fe8def28d1..66d9754331 100644
--- a/complex.c
+++ b/complex.c
@@ -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: */