summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-06-01 06:53:26 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-06-01 06:53:26 +0000
commitce2f4f852692a1583cbe15877f0c0f2384d53c0f (patch)
tree89660f4a67d04b4194187fff15f1eacc3aa84456 /string.c
parentccdcc7300d34889fcbbfb836e2261f35a89e3874 (diff)
string.c: trivial optimizations
* string.c (rb_str_aset): prefer BUILTIN_TYPE over TYPE after SPECIAL_CONST_P check. * string.c (rb_str_start_with): prefer RB_TYPE_P over switch by TYPE. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63543 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/string.c b/string.c
index 3bd6c74b35..36126eb805 100644
--- a/string.c
+++ b/string.c
@@ -4724,7 +4724,7 @@ rb_str_aset(VALUE str, VALUE indx, VALUE val)
}
if (SPECIAL_CONST_P(indx)) goto generic;
- switch (TYPE(indx)) {
+ switch (BUILTIN_TYPE(indx)) {
case T_REGEXP:
rb_str_subpat_set(str, indx, INT2FIX(0), val);
return val;
@@ -9628,14 +9628,11 @@ rb_str_start_with(int argc, VALUE *argv, VALUE str)
for (i=0; i<argc; i++) {
VALUE tmp = argv[i];
- switch (TYPE(tmp)) {
- case T_REGEXP:
- {
- bool r = rb_reg_start_with_p(tmp, str);
- if (r) return Qtrue;
- }
- break;
- default:
+ if (RB_TYPE_P(tmp, T_REGEXP)) {
+ if (rb_reg_start_with_p(tmp, str))
+ return Qtrue;
+ }
+ else {
StringValue(tmp);
rb_enc_check(str, tmp);
if (RSTRING_LEN(str) < RSTRING_LEN(tmp)) continue;