1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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
This commit is contained in:
nobu 2017-03-14 03:42:43 +00:00
parent 0088024233
commit 9fa56026e5

View file

@ -3181,19 +3181,11 @@ static VALUE
rb_str_cmp_m(VALUE str1, VALUE str2) rb_str_cmp_m(VALUE str1, VALUE str2)
{ {
int result; int result;
VALUE s = rb_check_string_type(str2);
if (!RB_TYPE_P(str2, T_STRING)) { if (NIL_P(s)) {
VALUE tmp = rb_check_funcall(str2, idTo_str, 0, 0); return rb_invcmp(str1, str2);
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);
} }
result = rb_str_cmp(str1, s);
return INT2FIX(result); return INT2FIX(result);
} }