vis

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

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

commit 9e2ee9d7dc871996cb6b0d83935148847e13e59a
parent 327eb04c02239f44c69fc6ac7856ba5a38321c89
Author: Alexey Dubinin <dubininalexey@gmail.com>
Date:   Wed, 28 Sep 2016 17:49:39 +0300

Replace win.file.lines with win.file:content for better performance

Diffstat:
Mvis.lua | 6+++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/vis.lua b/vis.lua @@ -193,7 +193,7 @@ vis.ftdetect.filetypes = { -- array of filetype detecting functions (win, filename, shebang, app) -> string vis.ftdetect.customdetectors = { function(win) - if win.file.lines[1] ~= nil and win.file.lines[1]:sub(1, 5) == '<?xml' then + if win.file:content(0, 5) == '<?xml' then return 'xml' end end, @@ -221,8 +221,8 @@ vis.filetype_detect = function(win) -- find out via shebang which application would run our file local shebang local app - if win.file.lines[1] ~= nil and win.file.lines[1]:sub(1, 2) == '#!' then - shebang = win.file.lines[1]:gsub('^#!%s*', '') + if win.file:content(0, 2) == '#!' then + shebang = win.file:content(0, 256):gsub('^#!%s*', ''):gsub('\n.*$', '') app = shebang:gsub('^/usr/bin/env%s*', ''):gsub('%s.*$', ''):gsub('^.*/', '') if #app == 0 then app = nil