From 7e9e0a2ca868aaa214fb38a79fe71da34d6e00da Mon Sep 17 00:00:00 2001 From: Georgi Kirilov Date: Fri, 31 Jan 2020 18:16:32 +0200 Subject: lexers: XML performance improvement the new pattern does more or less the same thing, but forward instead of backward. --- lua/lexers/xml.lua | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'lua') 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('=') * -- cgit v1.2.3