Feature #12788 ยป string_lstrip_improvement.patch
| 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;
|
||
|
}
|
||