diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-03-14 03:42:43 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-03-14 03:42:43 +0000 |
commit | e569c1f3adf7582591256ad3147004867b3c3d36 (patch) | |
tree | 5f2ec454dfc709d10fd3bb902481b30c4ecdc4c4 /string.c | |
parent | 12e0d3e7ce41a383634a7bd44cb1147f26c53568 (diff) | |
download | ruby-e569c1f3adf7582591256ad3147004867b3c3d36.tar.gz |
string.c: use rb_check_string_type
* string.c (rb_str_cmp_m): use rb_check_string_type for check and
conversion, instead of calling the conversion method directly.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57965 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r-- | string.c | 16 |
1 files changed, 4 insertions, 12 deletions
@@ -3181,19 +3181,11 @@ static VALUE rb_str_cmp_m(VALUE str1, VALUE str2) { int result; - - if (!RB_TYPE_P(str2, T_STRING)) { - VALUE tmp = rb_check_funcall(str2, idTo_str, 0, 0); - if (RB_TYPE_P(tmp, T_STRING)) { - result = rb_str_cmp(str1, tmp); - } - else { - return rb_invcmp(str1, str2); - } - } - else { - result = rb_str_cmp(str1, str2); + VALUE s = rb_check_string_type(str2); + if (NIL_P(s)) { + return rb_invcmp(str1, str2); } + result = rb_str_cmp(str1, s); return INT2FIX(result); } |