Content deleted Content added
Try to handle strings more efficiently |
Test using baked data to make fewer calls to p.strip() |
||
Line 7:
local p = {}
local getArgs = require("Module:Arguments").getArgs
local data = mw.loadData("Module:ISO 3166/data/National/sandbox")
local outdata = mw.loadData("Module:ISO 3166/data/National")
--[[----------F I N D N A M E----------]]-- -- Finds the name in the database
Line 13 ⟶ 14:
local function findname(code,cdata,qry)
local sqry = p.strip(qry)
if cdata["name"] and sqry==
or cdata["isoname"] and sqry==
or not cdata["nocode"] and sqry==code
or sqry==cdata["alpha3"] or sqry==cdata["numeric"]
Line 21 ⟶ 22:
end
for _,tname in pairs(cdata["isonames"] or {}) do
if sqry==
return true
end
end
for _,tname in pairs(cdata["altnames"] or {}) do
if sqry==
return true
end
Line 91 ⟶ 92:
-- Hyphen-sensitive
text = string.gsub(text,"[^%w%-]","") -- Remove non alpha-numeric -- Remove non alpha-numeric
return text
Line 115 ⟶ 116:
local hyphenPos = string.find(a1 or '', '-', 1, true)
if not hyphenPos then --No hyphen
return p.luacodeimpl(args)
Line 166 ⟶ 168:
alpha2 = "GB"
end
local sdata = mw.loadData("Module:ISO 3166/data/"..alpha2.."/sandbox")
local empty = true
for scode,scdata in pairs(sdata) do
Line 220 ⟶ 222:
if code2=="" then --3166-1 alpha-2 code
if data[code1] then
return (args.isoname or args.lang) and isoname(
or (
else
return '[[Category:Wikipedia page with obscure country]]'
Line 227 ⟶ 229:
else --3166-2 code
local sdata
local outsdata
if data[code1] then
sdata = mw.loadData("Module:ISO 3166/data/"..code1.."/sandbox")
outsdata = mw.loadData("Module:ISO 3166/data/"..code1)
else
return '[[Category:Wikipedia page with obscure country]]'
end
if sdata[code2] then
return (args.isoname or args.lang) and isoname(
or (
else
return '[[Category:Wikipedia page with obscure country]]'
|