diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-09-29 11:07:45 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-09-29 11:07:45 +0000 |
commit | 8e6e8e628888aa251f771ce8b3fe30a6b41a7a0e (patch) | |
tree | e531ed455f2ffb110e9a16de2161b3865a19d582 /struct.c | |
parent | 68f97d7851481e11ce90bb349345dc4caed00cf7 (diff) |
* use RB_TYPE_P which is optimized for constant types, instead of
comparison with TYPE.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33357 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'struct.c')
-rw-r--r-- | struct.c | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -43,7 +43,7 @@ rb_struct_s_members(VALUE klass) if (NIL_P(members)) { rb_raise(rb_eTypeError, "uninitialized struct"); } - if (TYPE(members) != T_ARRAY) { + if (!RB_TYPE_P(members, T_ARRAY)) { rb_raise(rb_eTypeError, "corrupted struct"); } return members; @@ -354,7 +354,7 @@ num_members(VALUE klass) { VALUE members; members = struct_ivar_get(klass, id_members); - if (TYPE(members) != T_ARRAY) { + if (!RB_TYPE_P(members, T_ARRAY)) { rb_raise(rb_eTypeError, "broken members"); } return RARRAY_LEN(members); @@ -644,7 +644,7 @@ rb_struct_aref(VALUE s, VALUE idx) { long i; - if (TYPE(idx) == T_STRING || TYPE(idx) == T_SYMBOL) { + if (RB_TYPE_P(idx, T_STRING) || RB_TYPE_P(idx, T_SYMBOL)) { return rb_struct_aref_id(s, rb_to_id(idx)); } @@ -709,7 +709,7 @@ rb_struct_aset(VALUE s, VALUE idx, VALUE val) { long i; - if (TYPE(idx) == T_STRING || TYPE(idx) == T_SYMBOL) { + if (RB_TYPE_P(idx, T_STRING) || RB_TYPE_P(idx, T_SYMBOL)) { return rb_struct_aset_id(s, rb_to_id(idx), val); } @@ -827,7 +827,7 @@ static VALUE rb_struct_equal(VALUE s, VALUE s2) { if (s == s2) return Qtrue; - if (TYPE(s2) != T_STRUCT) return Qfalse; + if (!RB_TYPE_P(s2, T_STRUCT)) return Qfalse; if (rb_obj_class(s) != rb_obj_class(s2)) return Qfalse; if (RSTRUCT_LEN(s) != RSTRUCT_LEN(s2)) { rb_bug("inconsistent struct"); /* should never happen */ @@ -897,7 +897,7 @@ static VALUE rb_struct_eql(VALUE s, VALUE s2) { if (s == s2) return Qtrue; - if (TYPE(s2) != T_STRUCT) return Qfalse; + if (!RB_TYPE_P(s2, T_STRUCT)) return Qfalse; if (rb_obj_class(s) != rb_obj_class(s2)) return Qfalse; if (RSTRUCT_LEN(s) != RSTRUCT_LEN(s2)) { rb_bug("inconsistent struct"); /* should never happen */ |