vis

a vi-like editor based on Plan 9's structural regular expressions

git clone https://9o.is/git/vis.git

commit 57cb07df65c7832a448348d10c387a1ee04a1012
parent 76cd6b2223e3be7e3c8a56110a789d3272cec639
Author: Georgi Kirilov <in.the@repo>
Date:   Fri, 31 Jan 2020 18:16:32 +0200

lexers: XML performance improvement

the new pattern does more or less the same thing, but forward
instead of backward.

Diffstat:
Mlua/lexers/xml.lua | 8+-------
1 file changed, 1 insertion(+), 7 deletions(-)

diff --git 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('=') *