Module:Sprite: Difference between revisions
Return a HTMLBuilder rather than a string. Doc shouldn't run through sprite function. |
Improve speed by only lowercasing each name once |
||
| Line 201: | Line 201: | ||
end | end | ||
local | local keyedData = {} | ||
for name in pairs( data.ids ) do | for name, idData in pairs( data.ids ) do | ||
table.insert( | table.insert( keyedData, { | ||
sortKey = mw.ustring.lower( name ), | |||
name = name, | |||
data = idData | |||
} ) | |||
end | end | ||
table.sort( | table.sort( keyedData, function( a, b ) | ||
return | return a.sortKey < b.sortKey | ||
end ) | end ) | ||
for _, | for _, data in ipairs( keyedData ) do | ||
local idData = data. | local idData = data.data | ||
local pos = idData.pos | local pos = idData.pos | ||
local section = sections[idData.section] | local section = sections[idData.section] | ||
| Line 224: | Line 228: | ||
local codeElem = names | local codeElem = names | ||
:tag( 'li' ):addClass( 'spritedoc-name' ) | :tag( 'li' ):addClass( 'spritedoc-name' ) | ||
:tag( 'code' ):wikitext( name ) | :tag( 'code' ):wikitext( data.name ) | ||
if idData.deprecated then | if idData.deprecated then | ||