Project

General

Profile

Feature #12788 ยป string_lstrip_improvement.patch

asterite (Ary Borenszweig), 09/26/2016 01:02 AM

View differences:

string.c (working copy)
const char *const start = s;
if (!s || s >= e) return 0;
/* remove spaces at head */
while (s < e) {
int n;
unsigned int cc = rb_enc_codepoint_len(s, e, &n, enc);
if (single_byte_optimizable(str)) {
while (s < e && ascii_isspace(*s)) s++;
}
else {
while (s < e) {
int n;
unsigned int cc = rb_enc_codepoint_len(s, e, &n, enc);
if (!rb_isspace(cc)) break;
s += n;
if (!rb_isspace(cc)) break;
s += n;
}
}
return s - start;
}
    (1-1/1)