Skip to content

Commit 09d998a

Browse files
committed
Speed up loading git.lua by around 35 milliseconds.
The savings could be more or less, depending on the computer's CPU speed.
1 parent 9ae5df2 commit 09d998a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

git.lua

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3026,7 +3026,10 @@ local function command_display_filter()
30263026
end
30273027

30283028
-- Initialize the argmatcher. This may be called repeatedly.
3029+
local ever_inited
30293030
local function init(argmatcher, full_init)
3031+
ever_inited = true
3032+
30303033
-- When doing a full init, must reset in order to maintain the sort order.
30313034
-- Full init is used from the setdelayinit callback function, for an alias
30323035
-- to be able to parse arguments for the command it aliases.
@@ -3107,7 +3110,6 @@ local cached_cwd
31073110
local cached_repo
31083111

31093112
local git_parser = parser()
3110-
init(git_parser, false--[[full_init]])
31113113
if git_parser.setdelayinit then
31123114
git_parser:setdelayinit(function (argmatcher)
31133115
local cwd = os.getcwd()
@@ -3120,8 +3122,13 @@ if git_parser.setdelayinit then
31203122
init(argmatcher, true--[[full_init]])
31213123
end
31223124
end
3125+
if not ever_inited then
3126+
init(git_parser, false--[[full_init]])
3127+
end
31233128
end
31243129
end)
3130+
else
3131+
init(git_parser, false--[[full_init]])
31253132
end
31263133

31273134
clink.arg.register_parser("git", git_parser)

0 commit comments

Comments
 (0)