]> granicus.if.org Git - onig/commitdiff
remove USE_SUNDAY_QUICK_SEARCH_ALGORITHM switch
authorK.Kosako <kkosako0@gmail.com>
Mon, 8 Oct 2018 08:03:16 +0000 (17:03 +0900)
committerK.Kosako <kkosako0@gmail.com>
Mon, 8 Oct 2018 08:03:16 +0000 (17:03 +0900)
src/regcomp.c
src/regexec.c
src/regint.h

index 78a340f520c9402bbe9c95d0010f120053683a7e..dc149690b9ab93ac5b21eb5ae2f3ec1b67154d21 100644 (file)
@@ -4618,7 +4618,6 @@ setup_tree(Node* node, regex_t* reg, int state, ScanEnv* env)
   return r;
 }
 
-#ifdef USE_SUNDAY_QUICK_SEARCH_ALGORITHM
 static int
 set_sunday_quick_search_skip_table(regex_t* reg, int case_expand,
                                    UChar* s, UChar* end,
@@ -4688,28 +4687,6 @@ set_sunday_quick_search_skip_table(regex_t* reg, int case_expand,
 
   return 0;
 }
-#else
-/* set skip map for Boyer-Moore-Horspool search */
-static int
-set_bmh_search_skip_table(UChar* s, UChar* end, OnigEncoding enc ARG_UNUSED,
-                          UChar skip[])
-{
-  int i, len;
-
-  len = (int )(end - s);
-  if (len < UCHAR_MAX) {
-    for (i = 0; i < CHAR_MAP_SIZE; i++) skip[i] = len;
-
-    for (i = 0; i < len - 1; i++)
-      skip[s[i]] = len - 1 - i;
-
-    return 0;
-  }
-  else {
-    return ONIGERR_PARSER_BUG;
-  }
-}
-#endif /* USE_SUNDAY_QUICK_SEARCH_ALGORITHM */
 
 
 #define OPT_EXACT_MAXLEN   24
@@ -5715,7 +5692,6 @@ set_optimize_exact(regex_t* reg, OptStr* e)
 
   if (e->case_fold) {
     reg->optimize = OPTIMIZE_STR_CASE_FOLD;
-#ifdef USE_SUNDAY_QUICK_SEARCH_ALGORITHM
     if (e->good_case_fold != 0) {
       if (e->len >= 2) {
         r = set_sunday_quick_search_skip_table(reg, 1,
@@ -5725,7 +5701,6 @@ set_optimize_exact(regex_t* reg, OptStr* e)
        reg->optimize = OPTIMIZE_STR_CASE_FOLD_FAST;
       }
     }
-#endif
   }
   else {
     int allow_reverse;
@@ -5734,13 +5709,8 @@ set_optimize_exact(regex_t* reg, OptStr* e)
       ONIGENC_IS_ALLOWED_REVERSE_MATCH(reg->enc, reg->exact, reg->exact_end);
 
     if (e->len >= 2 || (e->len >= 1 && allow_reverse)) {
-#ifdef USE_SUNDAY_QUICK_SEARCH_ALGORITHM
       r = set_sunday_quick_search_skip_table(reg, 0, reg->exact, reg->exact_end,
                                              reg->map, &(reg->map_offset));
-#else
-      r = set_bmh_search_skip_table(reg->exact, reg->exact_end,
-                                    reg->enc, reg->map);
-#endif
       if (r != 0) return r;
 
       reg->optimize = (allow_reverse != 0
index 530cc0617cc3090455e8dbdb63a12aeda3e5f5bd..d298f5b144014d44bc652212e9a1250e7c021cae 100644 (file)
@@ -4112,7 +4112,6 @@ slow_search_backward_ic(OnigEncoding enc, int case_fold_flag,
   return (UChar* )NULL;
 }
 
-#ifdef USE_SUNDAY_QUICK_SEARCH_ALGORITHM
 
 static UChar*
 sunday_quick_search_step_forward(regex_t* reg,
@@ -4251,77 +4250,6 @@ sunday_quick_search_case_fold(regex_t* reg,
   return (UChar* )NULL;
 }
 
-#else
-
-static UChar*
-bmh_search_step_forward(regex_t* reg,
-                        const UChar* target, const UChar* target_end,
-                        const UChar* text, const UChar* text_end,
-                        const UChar* text_range)
-{
-  const UChar *s, *se, *t, *p, *end;
-  const UChar *tail;
-  int skip, tlen1;
-
-#ifdef ONIG_DEBUG_SEARCH
-  fprintf(stderr,
-          "bmh_search_step_forward: text: %p, text_end: %p, text_range: %p\n",
-          text, text_end, text_range);
-#endif
-
-  tail = target_end - 1;
-  tlen1 = (int )(tail - target);
-  end = text_range;
-  if (end + tlen1 > text_end)
-    end = text_end - tlen1;
-
-  s = text;
-
-  while (s < end) {
-    p = se = s + tlen1;
-    t = tail;
-    while (*p == *t) {
-      if (t == target) return (UChar* )s;
-      p--; t--;
-    }
-    skip = reg->map[*se];
-    t = s;
-    do {
-      s += enclen(reg->enc, s);
-    } while ((s - t) < skip && s < end);
-  }
-
-  return (UChar* )NULL;
-}
-
-static UChar*
-bmh_search(regex_t* reg, const UChar* target, const UChar* target_end,
-           const UChar* text, const UChar* text_end, const UChar* text_range)
-{
-  const UChar *s, *t, *p, *end;
-  const UChar *tail;
-
-  end = text_range + (target_end - target);
-  if (end > text_end)
-    end = text_end;
-
-  tail = target_end - 1;
-  s = text + (tail - target);
-
-  while (s < end) {
-    p = s;
-    t = tail;
-    while (*p == *t) {
-      if (t == target) return (UChar* )p;
-      p--; t--;
-    }
-    s += reg->map[*s];
-  }
-
-  return (UChar* )NULL;
-}
-#endif /* USE_SUNDAY_QUICK_SEARCH_ALGORITHM */
-
 static UChar*
 map_search(OnigEncoding enc, UChar map[],
            const UChar* text, const UChar* text_range)
@@ -4436,31 +4364,17 @@ forward_search_range(regex_t* reg, const UChar* str, const UChar* end, UChar* s,
     break;
 
   case OPTIMIZE_STR_CASE_FOLD_FAST:
-#ifdef USE_SUNDAY_QUICK_SEARCH_ALGORITHM
     p = sunday_quick_search_case_fold(reg, reg->exact, reg->exact_end, p, end,
                                       range);
-#else
-    p = slow_search_ic(reg->enc, reg->case_fold_flag,
-                       reg->exact, reg->exact_end, p, end, range);
-#endif
     break;
 
   case OPTIMIZE_STR_FAST:
-#ifdef USE_SUNDAY_QUICK_SEARCH_ALGORITHM
     p = sunday_quick_search(reg, reg->exact, reg->exact_end, p, end, range);
-#else
-    p = bmh_search(reg, reg->exact, reg->exact_end, p, end, range);
-#endif
     break;
 
   case OPTIMIZE_STR_FAST_STEP_FORWARD:
-#ifdef USE_SUNDAY_QUICK_SEARCH_ALGORITHM
     p = sunday_quick_search_step_forward(reg, reg->exact, reg->exact_end,
                                          p, end, range);
-#else
-    p = bmh_search_step_forward(reg, reg->exact, reg->exact_end,
-                                p, end, range);
-#endif
     break;
 
   case OPTIMIZE_MAP:
index fb7a4a4250f5dde39f77453dbd012561c2de87e6..401876192b0faae53aa4078e983c033be29ec57f 100644 (file)
@@ -62,7 +62,6 @@
 #define USE_INSISTENT_CHECK_CAPTURES_IN_EMPTY_REPEAT    /* /(?:()|())*\2/ */
 #define USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE     /* /\n$/ =~ "\n" */
 #define USE_WARNING_REDUNDANT_NESTED_REPEAT_OPERATOR
-#define USE_SUNDAY_QUICK_SEARCH_ALGORITHM
 
 #define USE_RETRY_LIMIT_IN_MATCH