String#index should no longer take integer argument

This commit is contained in:
Yukihiro "Matz" Matsumoto
2015-09-22 19:10:03 +09:00
parent e47f0fc0c2
commit 2cb6c27781
2 changed files with 1 additions and 12 deletions
+1 -1
View File
@@ -12,7 +12,7 @@ class String
def each_line(&block) def each_line(&block)
# expect that str.index accepts an Integer for 1st argument as a byte data # expect that str.index accepts an Integer for 1st argument as a byte data
offset = 0 offset = 0
while pos = self.index(0x0a, offset) while pos = self.index("\n", offset)
block.call(self[offset, pos + 1 - offset]) block.call(self[offset, pos + 1 - offset])
offset = pos + 1 offset = pos + 1
end end
-11
View File
@@ -1389,17 +1389,6 @@ mrb_str_index_m(mrb_state *mrb, mrb_value str)
} }
switch (mrb_type(sub)) { switch (mrb_type(sub)) {
case MRB_TT_FIXNUM: {
mrb_int c = mrb_fixnum(sub);
mrb_int len = RSTRING_LEN(str);
unsigned char *p = (unsigned char*)RSTRING_PTR(str);
for (;pos<len;pos++) {
if (p[pos] == c) return mrb_fixnum_value(pos);
}
return mrb_nil_value();
}
default: { default: {
mrb_value tmp; mrb_value tmp;