Skip to content

Commit

Permalink
Git issue 495: Running time for failing fullmatch increases rapidly w…
Browse files Browse the repository at this point in the history
…ith input length

Re-enabled modified repeat guards due to regression in speed caused by excessive backtracking.
  • Loading branch information
Matthew Barnett committed Mar 23, 2023
1 parent 5954c51 commit 15cbd1e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions regex_3/_regex.c
Original file line number Diff line number Diff line change
Expand Up @@ -23178,7 +23178,10 @@ Py_LOCAL_INLINE(RE_STATUS_T) add_repeat_guards(PatternObject* pattern, RE_Node*
RE_STATUS_REF);

repeat_info = &pattern->repeat_info[node->values[0]];
repeat_info->status |= RE_STATUS_BODY;
/* Removing guard here to fix issue 494 and prevent
* regression of issue 495.
*/
/* repeat_info->status |= RE_STATUS_BODY; */

if (tail_result != RE_STATUS_REF)
repeat_info->status |= RE_STATUS_TAIL;
Expand Down Expand Up @@ -23639,7 +23642,7 @@ Py_LOCAL_INLINE(BOOL) optimise_pattern(PatternObject* pattern) {
/* Add position guards for repeat bodies containing a reference to a group
* or repeat tails followed at some point by a reference to a group.
*/
//add_repeat_guards(pattern, pattern->start_node);
add_repeat_guards(pattern, pattern->start_node);

/* Record the index of repeats and fuzzy sections within the body of atomic
* and lookaround nodes.
Expand Down
2 changes: 1 addition & 1 deletion regex_3/regex.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@
"VERSION1", "X", "VERBOSE", "W", "WORD", "error", "Regex", "__version__",
"__doc__", "RegexFlag"]

__version__ = "2.5.124"
__version__ = "2.5.125"

# --------------------------------------------------------------------
# Public interface.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setup(
name='regex',
version='2023.3.22',
version='2023.3.23',
description='Alternative regular expression module, to replace re.',
long_description=long_description,
long_description_content_type='text/x-rst',
Expand Down

0 comments on commit 15cbd1e

Please sign in to comment.