util.pluginloader: Extract Lua version once
authorKim Alvefur <zash@zash.se>
Mon, 05 Oct 2020 20:56:03 +0200
changeset 11133 387d442497e7
parent 11131 1d9cd1abc660
child 11134 10485a3ef78b
util.pluginloader: Extract Lua version once It's not going to change while the module is loaded.
util/pluginloader.lua
--- a/util/pluginloader.lua	Sat Oct 03 16:22:56 2020 +0200
+++ b/util/pluginloader.lua	Mon Oct 05 20:56:03 2020 +0200
@@ -8,6 +8,7 @@
 -- luacheck: ignore 113/CFG_PLUGINDIR
 
 local dir_sep, path_sep = package.config:match("^(%S+)%s(%S+)");
+local lua_version = _VERSION:match(" (.+)$");
 local plugin_dir = {};
 for path in (CFG_PLUGINDIR or "./plugins/"):gsub("[/\\]", dir_sep):gmatch("[^"..path_sep.."]+") do
 	path = path..dir_sep; -- add path separator to path end
@@ -36,7 +37,6 @@
 
 local function load_resource(plugin, resource)
 	resource = resource or "mod_"..plugin..".lua";
-	local lua_version = _VERSION:match(" (.+)$");
 	local names = {
 		"mod_"..plugin..dir_sep..plugin..dir_sep..resource; -- mod_hello/hello/mod_hello.lua
 		"mod_"..plugin..dir_sep..resource;                  -- mod_hello/mod_hello.lua