diff options
author | Guido van Rossum <guido@python.org> | 2003-04-14 17:59:34 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2003-04-14 17:59:34 (GMT) |
commit | 41c99e7f96f7a0f192839801c568d8a80dcc7091 (patch) | |
tree | 5733d278d932546d0b642dce7e631512da483f76 /Lib/sre_compile.py | |
parent | 44c62ef5ee2d48cfa0bd024507f19e47d987e6b3 (diff) | |
download | cpython-41c99e7f96f7a0f192839801c568d8a80dcc7091.zip cpython-41c99e7f96f7a0f192839801c568d8a80dcc7091.tar.gz cpython-41c99e7f96f7a0f192839801c568d8a80dcc7091.tar.bz2 |
SF patch #720991 by Gary Herron:
A small fix for bug #545855 and Greg Chapman's
addition of op code SRE_OP_MIN_REPEAT_ONE for
eliminating recursion on simple uses of pattern '*?' on a
long string.
Diffstat (limited to 'Lib/sre_compile.py')
-rw-r--r-- | Lib/sre_compile.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Lib/sre_compile.py b/Lib/sre_compile.py index bb17649..3e54819 100644 --- a/Lib/sre_compile.py +++ b/Lib/sre_compile.py @@ -55,8 +55,11 @@ def _compile(code, pattern, flags): _compile(code, av[2], flags) emit(OPCODES[SUCCESS]) code[skip] = len(code) - skip - elif _simple(av) and op == MAX_REPEAT: - emit(OPCODES[REPEAT_ONE]) + elif _simple(av) and op != REPEAT: + if op == MAX_REPEAT: + emit(OPCODES[REPEAT_ONE]) + else: + emit(OPCODES[MIN_REPEAT_ONE]) skip = len(code); emit(0) emit(av[0]) emit(av[1]) |