From cc0dc67bbbe1951ff90004bc987f78545625d772 Mon Sep 17 00:00:00 2001 From: 卜部昌平 Date: Fri, 7 May 2021 12:49:32 +0900 Subject: cdhash_cmp: can also take complex There are complex literals `123i`, which can also be a case condition. --- complex.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'complex.c') 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: */ -- cgit v1.2.3