Module:Citation/CS1: Difference between revisions
slightly reduce number of sub calls for performance
m>Dragons flight (len not length) |
m>Dragons flight (slightly reduce number of sub calls for performance) |
||
Line 106: | Line 106: | ||
local str = ''; | local str = ''; | ||
local comp = ''; | local comp = ''; | ||
local end_chr = ''; | |||
for _, value in ipairs( tbl ) do | for _, value in ipairs( tbl ) do | ||
if value == nil then value = ''; end | if value == nil then value = ''; end | ||
Line 120: | Line 121: | ||
if comp:sub(1,1) == duplicate_char then | if comp:sub(1,1) == duplicate_char then | ||
end_chr = str:sub(-1,-1); | |||
if end_chr == duplicate_char then | |||
str = str:sub(1,-2) .. value; | str = str:sub(1,-2) .. value; | ||
elseif str:sub(-3,-1) == duplicate_char .. "''" then | elseif end_chr == "'" then | ||
if str:sub(-3,-1) == duplicate_char .. "''" then | |||
elseif str:sub(-2,-1) == duplicate_char .. " " then | str = str:sub(1, -4) .. "''" .. value; | ||
else | |||
str = str .. value; | |||
end | |||
elseif end_chr == " " then | |||
if str:sub(-2,-1) == duplicate_char .. " " then | |||
str = str:sub(1,-3) .. value; | |||
else | |||
str = str .. value; | |||
end | |||
else | else | ||
str = str .. value; | str = str .. value; |