Would it be possible to add the full names of zone chat channels ("General - %s", "Trade - City" and "LocalDefense - %s")? I have an add-on that needs "Trade - City" for a unit test, and it's not in GlobalStrings.lua for some reason.
I have several CPU-heavy functions whose output I want to cache, but I need to limit the number of cache entries so the table won't grow large enough to cause hard page faults. What I've been doing so far is:
function LFMonitor:cacheLookup(table, item, fallback, disableCaching)
assert(item, "LFMonitor:cacheLookup called with nil item")
if disableCaching then
return fallback(item)
end
if not table.score then
table.score = {}
end
if table.score[item] then
return table.score[item]
else
local score = fallback(item)
if table.count >= table.max then
table.score[next(table.score)] = nil
else
table.count = table.count + 1
end
table.score[item] = score
return score
end
end
However, next() sometimes returns the newest index in the table, and it'd be better to remove the oldest index (since it's less likely to be used again soon). I'm also not sure whether adding and removing entries one-by-one is optimal.
0
0
However, next() sometimes returns the newest index in the table, and it'd be better to remove the oldest index (since it's less likely to be used again soon). I'm also not sure whether adding and removing entries one-by-one is optimal.