зеркало из https://github.com/github/ruby.git
string.c: fast path of lstrip_offset
* string.c (lstrip_offset): add a fast path in the case of single byte optimizable strings, as well as rstrip_offset. [ruby-core:77392] [Feature #12788] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56250 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
3973cc5820
Коммит
8d501ec021
|
@ -1,3 +1,9 @@
|
||||||
|
Mon Sep 26 14:10:54 2016 Ary Borenszweig <ary@esperanto.org.ar>
|
||||||
|
|
||||||
|
* string.c (lstrip_offset): add a fast path in the case of single
|
||||||
|
byte optimizable strings, as well as rstrip_offset.
|
||||||
|
[ruby-core:77392] [Feature #12788]
|
||||||
|
|
||||||
Mon Sep 26 12:00:12 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Mon Sep 26 12:00:12 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* gems/bundled_gems: update to minitest-5.9.1.
|
* gems/bundled_gems: update to minitest-5.9.1.
|
||||||
|
|
6
string.c
6
string.c
|
@ -8041,7 +8041,12 @@ lstrip_offset(VALUE str, const char *s, const char *e, rb_encoding *enc)
|
||||||
const char *const start = s;
|
const char *const start = s;
|
||||||
|
|
||||||
if (!s || s >= e) return 0;
|
if (!s || s >= e) return 0;
|
||||||
|
|
||||||
/* remove spaces at head */
|
/* remove spaces at head */
|
||||||
|
if (single_byte_optimizable(str)) {
|
||||||
|
while (s < e && ascii_isspace(*s)) s++;
|
||||||
|
}
|
||||||
|
else {
|
||||||
while (s < e) {
|
while (s < e) {
|
||||||
int n;
|
int n;
|
||||||
unsigned int cc = rb_enc_codepoint_len(s, e, &n, enc);
|
unsigned int cc = rb_enc_codepoint_len(s, e, &n, enc);
|
||||||
|
@ -8049,6 +8054,7 @@ lstrip_offset(VALUE str, const char *s, const char *e, rb_encoding *enc)
|
||||||
if (!rb_isspace(cc)) break;
|
if (!rb_isspace(cc)) break;
|
||||||
s += n;
|
s += n;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return s - start;
|
return s - start;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче