Jump to content

Module talk:Flags

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Moroboshi (talk | contribs) at 12:33, 22 July 2013 (Code change). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Code change

Hello I saw your module on it.wiki, and I woul like to make some changes to the code:

  1. declare local all variables, they are more efficient and quick to access and you dont pollute global namespace
  2. Why do you use a for loop to check if a key is in the table like:
for flagParameter,commonsFile in pairs(master.twoLetter) do 
    if flagParameter == territory.args[1]  then 
       commonsName = commonsFile 
       tempLink = commonsFile
     end
end

is simpler and quicker try to assign and check for nil

commonsFile = master.twoLetter[territory.args[1]]
if commonsFile then --check for nil
    commonsName = commonsFile 
    tempLink = commonsFile
end
  1. Why check for if territory.args[2] ~= "{{{2}}}" then ? AFAIK a paremeter call will be resolved before call the module and substituded by its value.

I will upload my changes to the sandbox for test.--Moroboshi (talk) 11:14, 22 July 2013 (UTC)[reply]