diff options
| author | 2021-12-29 15:23:50 -0500 | |
|---|---|---|
| committer | 2021-12-29 15:23:50 -0500 | |
| commit | 94e0cb161d3414b0a85763d9ba671f891d453dd8 (patch) | |
| tree | 644689f72200dfc9b779426bcdf7ddb836ed3e26 | |
| parent | change pm.parse api (diff) | |
optimize patok patternsv1.1.0
a lua pattern starting with ^ selects the first index
(rather than the true string start)
we can thus make the patterns fail for failed matches much faster
by manually prepending a '^'
for larger strings, this could be a gigantic speed improvement
| -rw-r--r-- | patok.lua | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -2,7 +2,7 @@ local meta = {} function meta:__call(p) if p == nil then return self.out end for k, v in pairs(p) do - table.insert(self.out.tokens, {name=k, pattern=v}) + table.insert(self.out.tokens, {name=k, pattern='^' .. v}) end return self end |
