Module:Namespace detect/data: Difference between revisions

IMO, aliasing variables like that makes readability worse
Enwikipedia>Mr. Stradivarius
(use a dedicated config page - Module:Namespace detect/config - for configuration data, and try and reduce unnecessary table lookups in the getParamMappings function)
Enwikipedia>Jackmcbarn
(IMO, aliasing variables like that makes readability worse)
Line 19:
-- }
--]]
local ustringLower = mw.ustring.lower
local tinsert = table.insert
local subjectNamespaces = mw.site.subjectNamespaces
local talk = cfg.talk
local mappings = {}
mappings[ustringLowermw.ustring.lower(mw.site.subjectNamespaces[0].name)] = {cfg.main}
mappings[cfg.talk] = {cfg.talk}
for nsid, ns in pairs(mw.site.subjectNamespaces) do
if nsid ~= 0 then -- Exclude main namespace.
local nsname = ustringLowermw.ustring.lower(ns.name)
local canonicalName = ustringLowermw.ustring.lower(ns.canonicalName)
mappings[nsname] = {nsname}
if canonicalName ~= nsname then
tinserttable.insert(mappings[nsname], canonicalName)
end
for _, alias in ipairs(ns.aliases) do
tinserttable.insert(mappings[nsname], ustringLowermw.ustring.lower(alias))
end
end