[k-takata/Onigmo] Remove code for backward BM search

The code has not been used for long.
(Oniguruma also removed this code.)

https://github.com/k-takata/Onigmo/commit/8796781fdd
This commit is contained in:
K.Takata 2019-01-29 19:00:02 +09:00 committed by Nobuyoshi Nakada
parent fb7f344b09
commit bbf9bf3fc5
No known key found for this signature in database
GPG Key ID: 3582D74E1FEE4465
Notes: git 2026-01-12 12:35:33 +00:00
3 changed files with 1 additions and 76 deletions

View File

@ -790,7 +790,7 @@ typedef struct re_pattern_buffer {
unsigned char *exact_end;
unsigned char map[ONIG_CHAR_TABLE_SIZE]; /* used as BM skip or char-map */
int *reserved1;
int *int_map_backward; /* BM skip for backward search */
int *reserved2;
OnigDistance dmin; /* min-distance of exact or map */
OnigDistance dmax; /* max-distance of exact or map */

View File

@ -5572,7 +5572,6 @@ onig_free_body(regex_t* reg)
if (IS_NOT_NULL(reg)) {
xfree(reg->p);
xfree(reg->exact);
xfree(reg->int_map_backward);
xfree(reg->repeat_range);
onig_free(reg->chain);
@ -5619,10 +5618,6 @@ onig_reg_copy(regex_t** nreg, regex_t* oreg)
(reg)->exact_end = (reg)->exact + exact_size;
}
if (IS_NOT_NULL(reg->int_map_backward)) {
if (COPY_FAILED(int_map_backward, sizeof(int) * ONIG_CHAR_TABLE_SIZE))
goto err_int_map_backward;
}
if (IS_NOT_NULL(reg->p)) {
if (COPY_FAILED(p, reg->alloc))
goto err_p;
@ -5649,8 +5644,6 @@ onig_reg_copy(regex_t** nreg, regex_t* oreg)
err_repeat_range:
xfree(reg->p);
err_p:
xfree(reg->int_map_backward);
err_int_map_backward:
xfree(reg->exact);
err:
xfree(reg);
@ -5667,7 +5660,6 @@ onig_memsize(const regex_t *reg)
if (IS_NULL(reg)) return 0;
if (IS_NOT_NULL(reg->p)) size += reg->alloc;
if (IS_NOT_NULL(reg->exact)) size += reg->exact_end - reg->exact;
if (IS_NOT_NULL(reg->int_map_backward)) size += sizeof(int) * ONIG_CHAR_TABLE_SIZE;
if (IS_NOT_NULL(reg->repeat_range)) size += reg->repeat_range_alloc * sizeof(OnigRepeatRange);
if (IS_NOT_NULL(reg->chain)) size += onig_memsize(reg->chain);
@ -5952,7 +5944,6 @@ onig_reg_init(regex_t* reg, OnigOptionType option,
(reg)->syntax = syntax;
(reg)->optimize = 0;
(reg)->exact = (UChar* )NULL;
(reg)->int_map_backward = (int* )NULL;
(reg)->chain = (regex_t* )NULL;
(reg)->p = (UChar* )NULL;

View File

@ -4530,58 +4530,6 @@ bm_search_ic(regex_t* reg, const UChar* target, const UChar* target_end,
return (UChar* )NULL;
}
#ifdef USE_INT_MAP_BACKWARD
static int
set_bm_backward_skip(UChar* s, UChar* end, OnigEncoding enc ARG_UNUSED,
int** skip)
{
int i, len;
if (IS_NULL(*skip)) {
*skip = (int* )xmalloc(sizeof(int) * ONIG_CHAR_TABLE_SIZE);
if (IS_NULL(*skip)) return ONIGERR_MEMORY;
}
len = (int )(end - s);
for (i = 0; i < ONIG_CHAR_TABLE_SIZE; i++)
(*skip)[i] = len;
for (i = len - 1; i > 0; i--)
(*skip)[s[i]] = i;
return 0;
}
static UChar*
bm_search_backward(regex_t* reg, const UChar* target, const UChar* target_end,
const UChar* text, const UChar* adjust_text,
const UChar* text_end, const UChar* text_start)
{
const UChar *s, *t, *p;
s = text_end - (target_end - target);
if (text_start < s)
s = text_start;
else
s = ONIGENC_LEFT_ADJUST_CHAR_HEAD(reg->enc, adjust_text, s, text_end);
while (s >= text) {
p = s;
t = target;
while (t < target_end && *p == *t) {
p++; t++;
}
if (t == target_end)
return (UChar* )s;
s -= reg->int_map_backward[*s];
s = ONIGENC_LEFT_ADJUST_CHAR_HEAD(reg->enc, adjust_text, s, text_end);
}
return (UChar* )NULL;
}
#endif
static UChar*
map_search(OnigEncoding enc, UChar map[],
const UChar* text, const UChar* text_range, const UChar* text_end)
@ -4828,21 +4776,7 @@ backward_search_range(regex_t* reg, const UChar* str, const UChar* end,
case ONIG_OPTIMIZE_EXACT_BM:
case ONIG_OPTIMIZE_EXACT_BM_NOT_REV:
#ifdef USE_INT_MAP_BACKWARD
if (IS_NULL(reg->int_map_backward)) {
int r;
if (s - range < BM_BACKWARD_SEARCH_LENGTH_THRESHOLD)
goto exact_method;
r = set_bm_backward_skip(reg->exact, reg->exact_end, reg->enc,
&(reg->int_map_backward));
if (r) return r;
}
p = bm_search_backward(reg, reg->exact, reg->exact_end, range, adjrange,
end, p);
#else
goto exact_method;
#endif
break;
case ONIG_OPTIMIZE_MAP: