aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames McCoy <jamessan@jamessan.com>2021-12-09 21:06:45 -0500
committerGitHub <noreply@github.com>2021-12-09 21:06:45 -0500
commit27648ee21803aabfced13b55b36671c4cf726703 (patch)
tree4ab3b4281d6313fc50ef79ac407cb433955aa5b2
parent8e64b21fed0bc83e9ac98949e2962c39ffa8b4e6 (diff)
parent51d5f0517f9d39baa034781ba8956772eba65c38 (diff)
downloadrneovim-27648ee21803aabfced13b55b36671c4cf726703.tar.gz
rneovim-27648ee21803aabfced13b55b36671c4cf726703.tar.bz2
rneovim-27648ee21803aabfced13b55b36671c4cf726703.zip
Merge pull request #16564 from glacambre/improve_test_harness_perf
test(helpers): optimize read_file_list
-rw-r--r--test/helpers.lua14
1 files changed, 13 insertions, 1 deletions
diff --git a/test/helpers.lua b/test/helpers.lua
index 09b113c01d..87431e4342 100644
--- a/test/helpers.lua
+++ b/test/helpers.lua
@@ -741,9 +741,20 @@ function module.read_file_list(filename, start)
if not file then
return nil
end
+
+ -- There is no need to read more than the last 2MB of the log file, so seek
+ -- to that.
+ local file_size = file:seek("end")
+ local offset = file_size - 2000000
+ if offset < 0 then
+ offset = 0
+ end
+ file:seek("set", offset)
+
local lines = {}
local i = 1
- for line in file:lines() do
+ local line = file:read("*l")
+ while line ~= nil do
if i >= start then
table.insert(lines, line)
if #lines > maxlines then
@@ -751,6 +762,7 @@ function module.read_file_list(filename, start)
end
end
i = i + 1
+ line = file:read("*l")
end
file:close()
return lines