aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorgi Kirilov <in.the@repo>2020-01-31 18:16:32 +0200
committerGeorgi Kirilov <in.the@repo>2020-01-31 18:23:16 +0200
commit7e9e0a2ca868aaa214fb38a79fe71da34d6e00da (patch)
treeb1f874a31780b259929de6ed03bc477595939dbc
parent24630d2d33fc76dbde5d37051667c7176ad5de93 (diff)
downloadvis-7e9e0a2ca868aaa214fb38a79fe71da34d6e00da.tar.gz
vis-7e9e0a2ca868aaa214fb38a79fe71da34d6e00da.tar.xz
lexers: XML performance improvement
the new pattern does more or less the same thing, but forward instead of backward.
-rw-r--r--lua/lexers/xml.lua8
1 files changed, 1 insertions, 7 deletions
diff --git a/lua/lexers/xml.lua b/lua/lexers/xml.lua
index d429ebb..7702444 100644
--- a/lua/lexers/xml.lua
+++ b/lua/lexers/xml.lua
@@ -20,13 +20,7 @@ local dq_str = l.delimited_range('"', false, true)
local string = #S('\'"') * l.last_char_includes('=') *
token(l.STRING, sq_str + dq_str)
-local in_tag = P(function(input, index)
- local before = input:sub(1, index - 1)
- local s, e = before:find('<[^>]-$'), before:find('>[^<]-$')
- if s and e then return s > e and index or nil end
- if s then return index end
- return input:find('^[^<]->', index) and index or nil
-end)
+local in_tag = #P((1 - S"><")^0 * ">")
-- Numbers.
local number = #l.digit * l.last_char_includes('=') *