aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChloe Kudryavtsev <toast@toast.cafe>2021-12-29 15:23:50 -0500
committerChloe Kudryavtsev <toast@toast.cafe>2021-12-29 15:23:50 -0500
commit94e0cb161d3414b0a85763d9ba671f891d453dd8 (patch)
tree644689f72200dfc9b779426bcdf7ddb836ed3e26
parentchange 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.lua2
1 files changed, 1 insertions, 1 deletions
diff --git a/patok.lua b/patok.lua
index f192733..55cc8dc 100644
--- a/patok.lua
+++ b/patok.lua
@@ -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