wesnoth/data/ai/lua/cache.lua
Celtic Minstrel 759b040069 fix whitespace
The whitespace-fixing script seems to be slightly different depending on the platform.
Even though it produces no effect in the CI, it made these changes locally on my Mac.
I'm committing them now so as to avoid unrelated files being changed in other pull requests.
2022-02-06 00:05:09 -05:00

24 lines
472 B
Lua

--! #textdomain wesnoth
return {
init = function(ai)
ai.cache = {}
ai.cache.data = {}
function ai.cache.update_cache(item, getter)
ai.cache.data[item] = ai.cache[getter]()
return ai.cache.data[item]
end
function ai.cache.get_cached_item(item, getter, validator)
if not ai.cache.data[item] or not ai.cache[validator]() then
local result = ai.cache.update_cache(item, getter)
return result
end
return ai.cache.data[item]
end
end
}