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 11:14, 22 July 2013 (Created page with '==Code change == Hello I saw your module on it.wiki, and I woul like to make some changes to the code: # declare local all variable, they are more efficient and ...'). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

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 variable, 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

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