Skip to content

Commit

Permalink
perf: avoid evaluating string templates if config.variables is not …
Browse files Browse the repository at this point in the history
…defined
  • Loading branch information
vyfor committed Jan 17, 2025
1 parent c152c71 commit 29efe00
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lua/cord/plugin/config/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,15 @@ function M.get(option, args)
local ty = type(option)

local variables = config.variables
if type(variables) == 'table' then
local vars_is_table = type(variables) == 'table'
if vars_is_table then
---@cast variables table
for k, v in pairs(variables) do
args[k] = v
end
end

if ty == 'string' then
if ty == 'string' and (vars_is_table or variables == true) then
option = option:gsub('%${(.-)}', function(var)
local arg = args[var]
if type(arg) == 'function' then
Expand Down

0 comments on commit 29efe00

Please sign in to comment.