reduce table lookups during initialization

This commit is contained in:
Tim 2015-02-05 10:03:07 +01:00
parent 1a1bfc3839
commit 76a9efff71
6 changed files with 33 additions and 54 deletions

View File

@ -1,9 +1,4 @@
local S
if rawget(_G, "intllib") then
S = intllib.Getter()
else
S = function(s) return s end
end
local S = unified_inventory.gettext
-- Create detached creative inventory after loading all mods
minetest.after(0.01, function()

View File

@ -3,12 +3,7 @@
-- Copyright (c) 2012 cornernote, Brett O'Donnell <cornernote@gmail.com>
-- License: GPLv3
local S
if rawget(_G, "intllib") then
S = intllib.Getter()
else
S = function(s) return s end
end
local S = unified_inventory.gettext
unified_inventory.register_page("bags", {
get_formspec = function(player)

View File

@ -3,33 +3,37 @@
local modpath = minetest.get_modpath(minetest.get_current_modname())
local worldpath = minetest.get_worldpath()
-- Data tables definitions
unified_inventory = {}
unified_inventory.activefilter = {}
unified_inventory.active_search_direction = {}
unified_inventory.alternate = {}
unified_inventory.current_page = {}
unified_inventory.current_searchbox = {}
unified_inventory.current_index = {}
unified_inventory.current_item = {}
unified_inventory.current_craft_direction = {}
unified_inventory.registered_craft_types = {}
unified_inventory.crafts_for = { usage = {}, recipe = {} }
unified_inventory.players = {}
unified_inventory.items_list_size = 0
unified_inventory.items_list = {}
unified_inventory.filtered_items_list_size = {}
unified_inventory.filtered_items_list = {}
unified_inventory.pages = {}
unified_inventory.buttons = {}
unified_inventory = {
activefilter = {},
active_search_direction = {},
alternate = {},
current_page = {},
current_searchbox = {},
current_index = {},
current_item = {},
current_craft_direction = {},
registered_craft_types = {},
crafts_for = {usage = {}, recipe = {} },
players = {},
items_list_size = 0,
items_list = {},
filtered_items_list_size = {},
filtered_items_list = {},
pages = {},
buttons = {},
-- Homepos stuff
unified_inventory.home_pos = {}
unified_inventory.home_filename =
worldpath.."/unified_inventory_home.home"
-- Homepos stuff
home_pos = {},
home_filename = worldpath.."/unified_inventory_home.home",
-- Default inventory page
unified_inventory.default = "craft"
-- Default inventory page
default = "craft",
-- intllib
gettext = rawget(_G, "intllib") and intllib.Getter() or function(s) return s end,
}
-- Disable default creative inventory
if rawget(_G, "creative_inventory") then

View File

@ -1,9 +1,4 @@
local S
if rawget(_G, "intllib") then
S = intllib.Getter()
else
S = function(s) return s end
end
local S = unified_inventory.gettext
-- This pair of encoding functions is used where variable text must go in
-- button names, where the text might contain formspec metacharacters.

View File

@ -1,9 +1,4 @@
local S
if rawget(_G, "intllib") then
S = intllib.Getter()
else
S = function(s) return s end
end
local S = unified_inventory.gettext
minetest.register_privilege("creative", {
description = "Can use the creative inventory",

View File

@ -1,9 +1,4 @@
local S
if rawget(_G, "intllib") then
S = intllib.Getter()
else
S = function(s) return s end
end
local S = unified_inventory.gettext
local hud_colors = {
{"#FFFFFF", 0xFFFFFF, S("White")},