Skip to content

fix(#1831): remove instrumentation #1968

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lua/nvim-tree/explorer/explore.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ local function populate_children(handle, cwd, node, git_status)
local nodes_by_path = utils.bool_record(node.nodes, "absolute_path")
local filter_status = filters.prepare(git_status)
while true do
local name, t = utils.fs_scandir_next_profiled(handle, cwd)
local name, t = vim.loop.fs_scandir_next(handle)
if not name then
break
end
Expand Down
8 changes: 4 additions & 4 deletions lua/nvim-tree/explorer/node-builders.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ local watch = require "nvim-tree.explorer.watch"
local M = {}

function M.folder(parent, absolute_path, name)
local handle = utils.fs_scandir_profiled(absolute_path)
local has_children = handle and utils.fs_scandir_next_profiled(handle, absolute_path) ~= nil
local handle = vim.loop.fs_scandir(absolute_path)
local has_children = handle and vim.loop.fs_scandir_next(handle) ~= nil

local node = {
type = "directory",
Expand Down Expand Up @@ -63,8 +63,8 @@ function M.link(parent, absolute_path, name)
local is_dir_link = (link_to ~= nil) and vim.loop.fs_stat(link_to).type == "directory"

if is_dir_link then
local handle = utils.fs_scandir_profiled(link_to)
has_children = handle and utils.fs_scandir_next_profiled(handle, link_to) ~= nil
local handle = vim.loop.fs_scandir(link_to)
has_children = handle and vim.loop.fs_scandir_next(handle) ~= nil
open = false
nodes = {}
end
Expand Down
4 changes: 2 additions & 2 deletions lua/nvim-tree/explorer/reload.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ end

function M.reload(node, git_status, unloaded_bufnr)
local cwd = node.link_to or node.absolute_path
local handle = utils.fs_scandir_profiled(cwd)
local handle = vim.loop.fs_scandir(cwd)
if not handle then
return
end
Expand All @@ -55,7 +55,7 @@ function M.reload(node, git_status, unloaded_bufnr)
local node_ignored = explorer_node.is_git_ignored(node)
local nodes_by_path = utils.key_by(node.nodes, "absolute_path")
while true do
local name, t = utils.fs_scandir_next_profiled(handle, cwd)
local name, t = vim.loop.fs_scandir_next(handle, cwd)
if not name then
break
end
Expand Down
48 changes: 0 additions & 48 deletions lua/nvim-tree/utils.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
local Iterator = require "nvim-tree.iterators.node-iterator"
local notify = require "nvim-tree.notify"
local log = require "nvim-tree.log"

local M = {
debouncers = {},
Expand Down Expand Up @@ -415,51 +414,4 @@ function M.is_nvim_tree_buf(bufnr)
return false
end

---Profile a call to vim.loop.fs_scandir
---This should be removed following resolution of #1831
---@param path string
---@return userdata|nil uv_fs_t
---@return string|nil type
---@return string|nil err (fail)
---@return string|nil name (fail)
function M.fs_scandir_profiled(path)
local pn = string.format("fs_scandir %s", path)
local ps = log.profile_start(pn)

local handle, err, name = vim.loop.fs_scandir(path)

if err or name then
log.line("profile", " %s err '%s'", pn, vim.inspect(err))
log.line("profile", " %s name '%s'", pn, vim.inspect(name))
end

log.profile_end(ps, pn)

return handle, err, name
end

---Profile a call to vim.loop.fs_scandir_next
---This should be removed following resolution of #1831
---@param handle userdata uv_fs_t
---@param tag string arbitrary
---@return string|nil name
---@return string|nil type
---@return string|nil err (fail)
---@return string|nil name (fail)
function M.fs_scandir_next_profiled(handle, tag)
local pn = string.format("fs_scandir_next %s", tag)
local ps = log.profile_start(pn)

local n, t, err, name = vim.loop.fs_scandir_next(handle)

if err or name then
log.line("profile", " %s err '%s'", pn, vim.inspect(err))
log.line("profile", " %s name '%s'", pn, vim.inspect(name))
end

log.profile_end(ps, pn)

return n, t, err, name
end

return M