summaryrefslogtreecommitdiff
path: root/regexec.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-05-29 13:56:38 (GMT)
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-05-29 13:56:38 (GMT)
commit9ff5f9c0713b5c3cc6bfe068645cb643cf7777cb (patch)
tree4e0da0316287d9ad80ead49a42668b09a86bd27b /regexec.c
parentb9e392fbedcdcb426ec2352cbd6e4011b11a8d3c (diff)
* regexec.c (match_at): make compilers optimize harder.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55202 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'regexec.c')
-rw-r--r--regexec.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/regexec.c b/regexec.c
index f52e55f..a70fbde 100644
--- a/regexec.c
+++ b/regexec.c
@@ -1561,9 +1561,6 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
mem_start_stk = (OnigStackIndex* )(repeat_stk + reg->num_repeat);
mem_end_stk = mem_start_stk + (num_mem + 1);
- for (i = 0; i <= num_mem; i++) {
- mem_start_stk[i] = mem_end_stk[i] = INVALID_STACK_INDEX;
- }
#else /* USE_SUBEXP_CALL */
/* Stack #0 not is used. */
n = reg->num_repeat + reg->num_mem * 2;
@@ -1579,10 +1576,14 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
mem_start_stk[1]..mem_start_stk[num_mem] */
mem_end_stk--; /* for index start from 1,
mem_end_stk[1]..mem_end_stk[num_mem] */
- for (i = 1; i <= num_mem; i++) {
- mem_start_stk[i] = mem_end_stk[i] = INVALID_STACK_INDEX;
- }
#endif /* USE_SUBEXP_CALL */
+ {
+ OnigStackIndex *pp = mem_start_stk;
+ for (; pp < (repeat_stk + n); pp+=2) {
+ pp[0] = INVALID_STACK_INDEX;
+ pp[1] = INVALID_STACK_INDEX;
+ }
+ }
#ifdef ONIG_DEBUG_MATCH
fprintf(stderr, "match_at: str: %"PRIdPTR" (%p), end: %"PRIdPTR" (%p), start: %"PRIdPTR" (%p), sprev: %"PRIdPTR" (%p)\n",