Sublime Forum

Suntax definition: do non-capturing groups improve performance?

#1

In a syntax definition, consider a match where I’m giving the same scope to all the matched text, instead of using the captures feature. In this situation does using non-capturing groups yield any performance improvement, or I can just use capturing groups carelessly to improve readability at no cost?

0 Likes

#2

This would depend heavily on the implementation details of the Sublime regexp engine. If it’s using a tagged-automaton implementation, then the difference should be minimal.

0 Likes

#3

After doing some investigation on that while working on a couple of syntaxes now, I found using small none-captureing regexes with smart push/set can increase performance by 10 to 15% compared to heavily used capture groups.

So yes it has an impact, but in most cases it doesn’t matter, whether a file is scoped within 50 or 55ms.

1 Like