summaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-12-23 06:53:51 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-12-23 06:53:51 +0000
commitc25c84777cf0bc96a0b985ca1ffda09aa8052d24 (patch)
treee799a7fe13f58635f10576e25c5d039abecd6d80 /hash.c
parent21e74f54816b147c0515d0f6c019d3e87fb237d2 (diff)
hash.c: reduce warning
* hash.c (HAS_EXTRA_STATES): warn extra states only when something differ. [ruby-core:59254] [Bug #9275] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44359 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/hash.c b/hash.c
index 4442f785f7..c84968ed57 100644
--- a/hash.c
+++ b/hash.c
@@ -28,12 +28,23 @@
#endif
#define HAS_EXTRA_STATES(hash, klass) ( \
- (klass = rb_obj_class(hash)) != rb_cHash || \
- (klass = 0, \
+ (klass = has_extra_methods(rb_obj_class(hash))) != 0 || \
FL_TEST((hash), FL_EXIVAR|FL_TAINT|HASH_PROC_DEFAULT) || \
!NIL_P(RHASH_IFNONE(hash))))
#define HASH_REJECT_COPY_EXTRA_STATES 1
+static VALUE
+has_extra_methods(VALUE klass)
+{
+ const VALUE base = rb_cHash;
+ VALUE c = klass;
+ while (c != base) {
+ st_table *mtbl = RCLASS_M_TBL(c);
+ if (mtbl && mtbl->num_entries) return klass;
+ }
+ return 0;
+}
+
static VALUE rb_hash_s_try_convert(VALUE, VALUE);
/*