feat(compiler): reduce bytecode size (#169)

* feat(compiler): reduce bytecode size

* added credits to nullchilly properly

---------

Co-authored-by: Siduck siduck@tutanota.com>
v2.5
Null Chilly 3 years ago committed by GitHub
parent 7b1f22a690
commit eea1c3155a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -100,20 +100,18 @@ M.table_to_str = function(tb)
end
M.saveStr_to_cache = function(filename, tb)
-- Thanks to https://github.com/EdenEast/nightfox.nvim
-- Thanks to https://github.com/nullchilly and https://github.com/EdenEast/nightfox.nvim
-- It helped me understand string.dump stuff
local bg_opt = "vim.opt.bg='" .. M.get_theme_tb "type" .. "'"
local defaults_cond = filename == "defaults" and bg_opt or ""
local cache_path = vim.fn.stdpath "cache" .. "/nvchad/base46/"
local lines = 'require("base46").compiled = string.dump(function()' .. defaults_cond .. M.table_to_str(tb) .. "end)"
local lines = "return string.dump(function()" .. defaults_cond .. M.table_to_str(tb) .. "end, true)"
local file = io.open(cache_path .. filename, "wb")
loadstring(lines, "=")()
if file then
file:write(require("base46").compiled)
file:write(loadstring(lines)())
file:close()
end
end

Loading…
Cancel
Save