summaryrefslogtreecommitdiff
path: root/regexec.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-05-19 08:25:03 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-05-19 08:25:03 +0000
commit44cd8e457b808173147c499408ffc5e908f236dc (patch)
tree357c92a92120e9e79054dbc58171b956e3d37e7f /regexec.c
parent48a42a0387a0924955c8cf31f880bdecbf6023a8 (diff)
downloadruby-44cd8e457b808173147c499408ffc5e908f236dc.tar.gz
* regparse.c (PINC): use optimized enclen() instead of
ONIGENC_MBC_ENC_LEN(). * regparse.c (PFETCH): ditto. * regparse.c (PFETCH): small optimization. * regexec.c (slow_search): single byte encoding optimization. * regenc.h (enclen): avoid calling function when encoding's min_len == max_len. * re.c (rb_reg_regsub): rb_enc_ascget() optimization for single byte encoding. * re.c (rb_reg_search): avoid allocating new re_registers if we already have MatchData. * re.c (match_init_copy): avoid unnecessary onig_region_free() before onig_region_copy. * encoding.c (rb_enc_get_index): remove implicit enc_capable check each time. * encoding.c (rb_enc_set_index): ditto. * encoding.c (enc_compatible_p): small refactoring. * include/ruby/encoding.h (rb_enc_dummy_p): inline rb_enc_dummy_p() and export related code. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16477 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'regexec.c')
-rw-r--r--regexec.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/regexec.c b/regexec.c
index b9947d8f93..a2d6993d08 100644
--- a/regexec.c
+++ b/regexec.c
@@ -2758,16 +2758,25 @@ slow_search(OnigEncoding enc, UChar* target, UChar* target_end,
s = (UChar* )text;
+ if (enc->max_enc_len == enc->min_enc_len) {
+ int n = enc->max_enc_len;
+
+ while (s < end) {
+ if (*s == *target) {
+ p = s + 1;
+ t = target + 1;
+ if (memcmp(t, p, target_end - t) == 0)
+ return s;
+ }
+ s += n;
+ }
+ return (UChar*)NULL;
+ }
while (s < end) {
if (*s == *target) {
p = s + 1;
t = target + 1;
- while (t < target_end) {
- if (*t != *p++)
- break;
- t++;
- }
- if (t == target_end)
+ if (memcmp(t, p, target_end - t) == 0)
return s;
}
s += enclen(enc, s, end);