From 8bf3595e3a05f0cea7f12c463a0df09e4010cd1c Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Mon, 8 Sep 2014 16:38:51 +0100 Subject: users/19059 based on users/19058: remove ineffiency with multiple * matches --- Src/pattern.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'Src') diff --git a/Src/pattern.c b/Src/pattern.c index 94a299ebb..df5e602ca 100644 --- a/Src/pattern.c +++ b/Src/pattern.c @@ -3012,6 +3012,16 @@ patmatch(Upat prog) break; case P_STAR: /* Handle specially for speed, although really P_ONEHASH+P_ANY */ + while (P_OP(next) == P_STAR) { + /* + * If there's another * following we can optimise it + * out. Chains of *'s can give pathologically bad + * performance. + */ + scan = next; + next = PATNEXT(scan); + } + /*FALLTHROUGH*/ case P_ONEHASH: case P_TWOHASH: /* -- cgit 1.4.1