--- _regex.c 2010-12-31 01:08:35.340892999 -0800 +++ _regex.c.fast 2010-12-31 01:08:29.523892999 -0800 @@ -252,7 +252,6 @@ typedef struct RE_RepeatInfo { int id; int guards; - BOOL inner; } RE_RepeatInfo; /* The state object used during matching. */ @@ -375,7 +374,6 @@ RE_Node* end; BOOL save_captures; BOOL has_captures; - size_t repeat_depth; } RE_CompileArgs; typedef struct JoinInfo { @@ -4450,22 +4448,16 @@ guard_list->sorted = 0; } } else { - PatternObject* pattern; - - pattern = state->pattern; - - for (i = 0; i < (size_t)pattern->repeat_count; i++) { + for (i = 0; i < (size_t)state->pattern->repeat_count; i++) { RE_GuardList* guard_list; - if (pattern->repeat_info[i].inner) { - guard_list = &state->repeats[i].body_guard_list; - guard_list->count = 0; - guard_list->sorted = 0; + guard_list = &state->repeats[i].body_guard_list; + guard_list->count = 0; + guard_list->sorted = 0; - guard_list = &state->repeats[i].tail_guard_list; - guard_list->count = 0; - guard_list->sorted = 0; - } + guard_list = &state->repeats[i].tail_guard_list; + guard_list->count = 0; + guard_list->sorted = 0; } } } @@ -4489,6 +4481,7 @@ RE_CODE (*char_at)(void* text, Py_ssize_t pos); BOOL (*has_property)(RE_CODE property, RE_CODE ch); RE_GroupInfo* group_info; + RE_RepeatInfo* repeat_info; Py_ssize_t step; BOOL has_groups; RE_Node* node; @@ -4537,6 +4530,7 @@ char_at = state->char_at; has_property = encoding->has_property; group_info = pattern->group_info; + repeat_info = pattern->repeat_info; step = state->reverse ? -1 : 1; has_groups = pattern->group_count > 0; @@ -10420,22 +10414,20 @@ } /* Records a repeat. */ -Py_LOCAL_INLINE(BOOL) record_repeat(PatternObject* pattern, int index, size_t - repeat_depth) { +Py_LOCAL_INLINE(BOOL) record_repeat(PatternObject* pattern, int id) { Py_ssize_t old_capacity; Py_ssize_t new_capacity; + RE_RepeatInfo* new_repeat_info; /* Increase the storage capacity to include the new entry if it's * insufficient. */ old_capacity = pattern->repeat_info_capacity; new_capacity = pattern->repeat_info_capacity; - while (index >= new_capacity) + while (id >= new_capacity) new_capacity += 16; if (new_capacity > old_capacity) { - RE_RepeatInfo* new_repeat_info; - new_repeat_info = (RE_RepeatInfo*)re_realloc(pattern->repeat_info, new_capacity * sizeof(RE_RepeatInfo)); if (!new_repeat_info) @@ -10447,10 +10439,8 @@ pattern->repeat_info_capacity = new_capacity; } - if (index >= pattern->repeat_count) - pattern->repeat_count = index + 1; - - pattern->repeat_info[index].inner = repeat_depth > 0; + if (id >= pattern->repeat_count) + pattern->repeat_count = id + 1; return TRUE; } @@ -11096,8 +11086,7 @@ /* Create the nodes for the repeat. */ repeat_node = create_node(args->pattern, greedy ? RE_OP_GREEDY_REPEAT : RE_OP_LAZY_REPEAT, FALSE, args->forward ? 1 : -1, 4); - if (!repeat_node || !record_repeat(args->pattern, index, - args->repeat_depth)) + if (!repeat_node || !record_repeat(args->pattern, index)) return FALSE; repeat_node->values[0] = index; @@ -11110,7 +11099,6 @@ subargs.min_width = 0; subargs.save_captures = TRUE; subargs.has_captures = FALSE; - ++subargs.repeat_depth; if (!build_sequence(&subargs)) return FALSE; @@ -11521,7 +11509,6 @@ args.min_width = 0; args.save_captures = FALSE; args.has_captures = FALSE; - args.repeat_depth = 0; if (!build_sequence(&args)) return FALSE;