mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
2000-01-18
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@607 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
dde62bcd2e
commit
e5ed1780af
7 changed files with 26 additions and 51 deletions
34
struct.c
34
struct.c
|
@ -523,38 +523,6 @@ rb_struct_equal(s, s2)
|
|||
return Qtrue;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
rb_struct_eql(s, s2)
|
||||
VALUE s, s2;
|
||||
{
|
||||
long i;
|
||||
|
||||
if (TYPE(s2) != T_STRUCT) return Qfalse;
|
||||
if (CLASS_OF(s) != CLASS_OF(s2)) return Qfalse;
|
||||
if (RSTRUCT(s)->len != RSTRUCT(s2)->len) {
|
||||
rb_bug("inconsistent struct"); /* should never happen */
|
||||
}
|
||||
|
||||
for (i=0; i<RSTRUCT(s)->len; i++) {
|
||||
if (!rb_eql(RSTRUCT(s)->ptr[i], RSTRUCT(s2)->ptr[i])) return Qfalse;
|
||||
}
|
||||
return Qtrue;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
rb_struct_hash(s)
|
||||
VALUE s;
|
||||
{
|
||||
long i;
|
||||
int h;
|
||||
|
||||
h = CLASS_OF(s);
|
||||
for (i=0; i<RSTRUCT(s)->len; i++) {
|
||||
h ^= rb_hash(RSTRUCT(s)->ptr[i]);
|
||||
}
|
||||
return INT2FIX(h);
|
||||
}
|
||||
|
||||
static VALUE
|
||||
rb_struct_size(s)
|
||||
VALUE s;
|
||||
|
@ -574,8 +542,6 @@ Init_Struct()
|
|||
rb_define_method(rb_cStruct, "clone", rb_struct_clone, 0);
|
||||
|
||||
rb_define_method(rb_cStruct, "==", rb_struct_equal, 1);
|
||||
rb_define_method(rb_cStruct, "eql?", rb_struct_eql, 1);
|
||||
rb_define_method(rb_cStruct, "hash", rb_struct_hash, 0);
|
||||
|
||||
rb_define_method(rb_cStruct, "to_s", rb_struct_to_s, 0);
|
||||
rb_define_method(rb_cStruct, "inspect", rb_struct_inspect, 0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue