mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
perf: only call is_compressed_tar when the file list is empty
This commit is contained in:
parent
5142354702
commit
828331e830
1 changed files with 4 additions and 6 deletions
|
|
@ -2,12 +2,10 @@ local M = {}
|
||||||
|
|
||||||
function M:peek(job)
|
function M:peek(job)
|
||||||
local limit = job.area.h
|
local limit = job.area.h
|
||||||
local files, bound, err = nil, nil, nil
|
local files, bound, err = self.list_files({ "-p", tostring(job.file.path) }, job.skip, limit)
|
||||||
|
|
||||||
if M.is_compressed_tar(job.file.path) then
|
if (#files == 1 and files[1].path:find(".+%.tar$")) or (#files == 0 and M.is_compressed_tar(job.file.path)) then
|
||||||
files, bound, err = self.list_files_tar({ "-p", tostring(job.file.path) }, job.skip, limit)
|
files, bound, err = self.list_tar_files({ "-p", tostring(job.file.path) }, job.skip, limit)
|
||||||
else
|
|
||||||
files, bound, err = self.list_files({ "-p", tostring(job.file.path) }, job.skip, limit)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if err then
|
if err then
|
||||||
|
|
@ -179,7 +177,7 @@ end
|
||||||
---@return table files
|
---@return table files
|
||||||
---@return integer bound
|
---@return integer bound
|
||||||
---@return Error? err
|
---@return Error? err
|
||||||
function M.list_files_tar(args, skip, limit)
|
function M.list_tar_files(args, skip, limit)
|
||||||
local childX, childL = M.spawn_7z_piped(
|
local childX, childL = M.spawn_7z_piped(
|
||||||
{ "x", "-so", table.unpack(args) },
|
{ "x", "-so", table.unpack(args) },
|
||||||
{ "l", "-ba", "-slt", "-ttar", "-sccUTF-8", "-si" }
|
{ "l", "-ba", "-slt", "-ttar", "-sccUTF-8", "-si" }
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue