79 548
contributi
m (mw.loadData (non credo cambi troppo perché poi questo modulo viene mw.loadDato a sua volta)) |
(Reducing size of PokéMoves/data pt1 *** sovrascritto il testo esistente ***) |
||
many files, and this module acts as an entry points that switches calls to
the underlying real data modules.
=== IMPLEMENTATION NOTES▼
TODO: choose implementation (merge or metatable switch)▼
Pro switch:▼
* Learnlist only accesses this module twice (actually four times, but▼
three of them are nearby so it can be accessed once putting it in a local▼
variable)▼
* Movepokes traverse the whole table, but I can add here a function to traverse▼
the whole data module that is efficient▼
* Wikilib-learnlist have a few functions accessing points of this table, but▼
notihng too expensive (I think)▼
Pro merge:▼
* Movelist pays this a lot because it makes some accesses to a different poke▼
for each row. In small pages this would favour switch, but big pages are▼
those with performances problems, and those favour the merge (maybe, I don't▼
know the relative cost)▼
=== MODULE STRUCTURE
the case for alternative forms) and that each of these has all siz kinds.
However it is not true that for each kind you can find any generation.
▲=== IMPLEMENTATION NOTES
▲TODO: choose implementation (merge or metatable switch)
▲Pro switch:
▲* Learnlist only accesses this module twice (actually four times, but
▲ three of them are nearby so it can be accessed once putting it in a local
▲ variable)
▲* Movepokes traverse the whole table, but I can add here a function to traverse
▲ the whole data module that is efficient
▲* Wikilib-learnlist have a few functions accessing points of this table, but
▲ notihng too expensive (I think)
▲Pro merge:
▲* Movelist pays this a lot because it makes some accesses to a different poke
▲ for each row. In small pages this would favour switch, but big pages are
▲ those with performances problems, and those favour the merge (maybe, I don't
▲ know the relative cost)
Actually merge seems as fast as switch, and it's simpler both to code and to
use
--]]
-- ========================== Switch implementation ===========================
-- local m = {}
--
-- local data0 = mw.loadData('Modulo:PokéMoves/data/0')
-- local data1 = mw.loadData('Modulo:PokéMoves/data/1')
--
-- m.__index = function(_, key)
-- local possRes = data0[key]
-- if possRes then
-- return possRes
-- else
-- return data1[key]
-- end
-- end
--
-- setmetatable(m, m)
--
-- -- Utility to iterate over all the data module
-- m.iterate = function(f)
-- for k, v in pairs(data0) do
-- f(v, k)
-- end
-- for k, v in pairs(data1) do
-- f(v, k)
-- end
-- end
-- =========================== Merge implementation ===========================
local m = require('Modulo:PokéMoves/data/0')
local data1 =
for k, v in pairs(data1) do
|