From 3949694f6351f0cf7a4b68d11667ca1c893de5e0 Mon Sep 17 00:00:00 2001 From: knu Date: Wed, 1 Nov 2006 05:01:43 +0000 Subject: * ext/digest/lib/digest/hmac.rb (Digest::HMAC::update): Minor optimization. * ext/digest/digest.c (rb_digest_instance_equal): Allow comparing a digest instance with another of a different class. git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8@11254 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ ext/digest/digest.c | 8 ++++---- ext/digest/lib/digest/hmac.rb | 3 ++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 42ed74bab..291f8c99b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Wed Nov 1 02:41:38 2006 Akinori MUSHA + + * ext/digest/lib/digest/hmac.rb (Digest::HMAC::update): Minor + optimization. + + * ext/digest/digest.c (rb_digest_instance_equal): Allow comparing + a digest instance with another of a different class. + Wed Nov 1 01:05:13 2006 NAKAMURA Usaku * eval.c (rb_call0): fixed bug of zsuper with both of opt and rest. diff --git a/ext/digest/digest.c b/ext/digest/digest.c index 5d58149b5..c4a58cf3f 100644 --- a/ext/digest/digest.c +++ b/ext/digest/digest.c @@ -286,16 +286,16 @@ rb_digest_instance_inspect(VALUE self) * digest_obj == string -> boolean * * If a string is given, checks whether it is equal to the hex-encoded - * hash value of the digest object. If another instance of the same - * digest class is given, checks whether they have the same hash - * value. Otherwise returns false. + * hash value of the digest object. If another digest instance is + * given, checks whether they have the same hash value. Otherwise + * returns false. */ static VALUE rb_digest_instance_equal(VALUE self, VALUE other) { VALUE str1, str2; - if (rb_obj_class(self) == rb_obj_class(other)) { + if (rb_obj_is_kind_of(other, rb_mDigest_Instance) == Qtrue) { str1 = rb_digest_instance_digest(0, 0, self); str2 = rb_digest_instance_digest(0, 0, other); } else { diff --git a/ext/digest/lib/digest/hmac.rb b/ext/digest/lib/digest/hmac.rb index a6415a156..b42fef98d 100644 --- a/ext/digest/lib/digest/hmac.rb +++ b/ext/digest/lib/digest/hmac.rb @@ -69,7 +69,8 @@ module Digest end def update(text) - @md.reset.update(@opad + @md.digest(@ipad + text)) + # @md is reset when digest() returns + @md.update(@opad + @md.digest(@ipad + text)) self end -- cgit