WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
NEW
152578
RegExp with anchor negation and grouping performance
https://bugs.webkit.org/show_bug.cgi?id=152578
Summary
RegExp with anchor negation and grouping performance
shahar.soel
Reported
2015-12-28 16:41:19 PST
reproduced here:
https://jsperf.com/regexp-negation-in-group/5
Expected: * Similar performance for these two regExps * Performance for these RegExp.test should be independent of input size as they anchor to the start of the input. var noGroup = /^"[^\\"]+"/; var oneGroup = /^"(:?[^\\"])+"/; Actual: * for oneGroup regExp the performance is much worse. anywhere from x30 slower for a single line input to 5 orders of magnitude for a 10000 lines input. When running the benchmark on other browsers (chrome/firefox) The input size does not affect the performance. Thanks. Shahar.
Attachments
Add attachment
proposed patch, testcase, etc.
shahar.soel
Comment 1
2015-12-30 07:28:58 PST
fixed the jsperf example (was using wrong syntax for none capturing groups)
http://jsperf.com/regexp-negation-in-group/6
shahar.soel
Comment 2
2016-08-08 00:35:49 PDT
JSPerf is down so I've added a reproducing jsfiddle instead.
https://jsfiddle.net/cbepLyum/2/
(open the console to see the results).
Pierre-Yves Gérardy
Comment 3
2020-02-12 06:02:05 PST
There is still a slowdown when using groups, but it is now by a constant factor of ~4, rather than dependent on the subject length. Surprisingly, the RegExp with two non-capturing groups is 10-20% faster than the one with only one.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug