diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-10-13 09:59:22 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-10-13 09:59:22 +0000 |
commit | fa8b08b4248d66a172369f4654fec9bdba8c748f (patch) | |
tree | b1217f07f36c92fca08b5f5ee720dc5596de17ff /string.c | |
parent | 83a01e6f529b80a876508b9501b64e8f1f1414da (diff) |
Prefer `rb_fstring_lit` over `rb_fstring_cstr`
The former states explicitly that the argument must be a literal,
and can optimize away `strlen` on all compilers.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65059 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r-- | string.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -4294,7 +4294,7 @@ rb_str_upto_each(VALUE beg, VALUE end, int excl, int (*each)(VALUE, VALUE), VALU } else { ID op = excl ? '<' : idLE; - VALUE args[2], fmt = rb_fstring_cstr("%.*d"); + VALUE args[2], fmt = rb_fstring_lit("%.*d"); args[0] = INT2FIX(width); while (rb_funcall(b, op, 1, e)) { @@ -4337,7 +4337,7 @@ rb_str_upto_endless_each(VALUE beg, int (*each)(VALUE, VALUE), VALUE arg) /* both edges are all digits */ if (is_ascii_string(beg) && ISDIGIT(RSTRING_PTR(beg)[0]) && all_digits_p(RSTRING_PTR(beg), RSTRING_LEN(beg))) { - VALUE b, args[2], fmt = rb_fstring_cstr("%.*d"); + VALUE b, args[2], fmt = rb_fstring_lit("%.*d"); int width = RSTRING_LENINT(beg); b = rb_str_to_inum(beg, 10, FALSE); if (FIXNUM_P(b)) { |