Skip to content

Commit

Permalink
digest.c: call to_s once
Browse files Browse the repository at this point in the history
* ext/digest/digest.c (rb_digest_instance_equal): no need to call
  `to_s` twice.  [Bug #9913]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46371 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
nobu committed Jun 7, 2014
1 parent 4169440 commit 6351787
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Sat Jun 7 12:28:53 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>

* ext/digest/digest.c (rb_digest_instance_equal): no need to call
`to_s` twice. [Bug #9913]

Sat Jun 7 11:35:01 2014 Tanaka Akira <akr@fsij.org>

* object.c (rb_mod_initialize_clone): Override Kernel#initialize_clone
Expand Down
7 changes: 3 additions & 4 deletions ext/digest/digest.c
Original file line number Diff line number Diff line change
Expand Up @@ -370,11 +370,10 @@ rb_digest_instance_equal(VALUE self, VALUE 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 if (!NIL_P(rb_check_string_type(other))) {
str1 = rb_digest_instance_to_s(self);
str2 = other;
} else {
return Qfalse;
str1 = rb_digest_instance_to_s(self);
str2 = rb_check_string_type(other);
if (NIL_P(str2)) return Qfalse;
}

/* never blindly assume that subclass methods return strings */
Expand Down

0 comments on commit 6351787

Please sign in to comment.