Module:User: Difference between revisions

From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
add comments
m (Mr. Stradivarius moved page Module:User:Mr. Stradivarius/user to Module:User without leaving a redirect: use this to implement Template:User - it should be about twice as fast as the existing template)
(add comments)
Line 1:
--[=[
-- This module implements {{user}}. {{user}} is a high-use template, sometimes
-- with thousands of transclusions on a page. This module optimises the
-- template's performance by reducing the number of parameters called from
-- wikitext, while still allowing all the features provided by
-- [[Module:UserLinks]]. It is about twice as fast as the version of {{user}}
-- that called the {{user-multi}} template from wikitext.
--]=]
 
local mUserLinks = require('Module:UserLinks')
local mShared = require('Module:UserLinks/shared')
Line 16 ⟶ 25:
 
function p.main(frame)
-- Grab the user, project and lang args from wikitext.
local argKeys = {
user = {
Line 41 ⟶ 51:
if value then
args[argKey] = value
-- If we have found a value, break the loop. For the average
-- invocation this saves two argument lookups.
break
end
end
end
-- Generate options. Some of these need wikitext args also.
local options = {
span = false,
Line 50 ⟶ 64:
isDemo = yesno(validateArg(origArgs.demo))
}
-- Input the codes directly. This saves two argument lookups for each
-- invocation.
local codes = {'t', 'c'}
-- Plug the data into [[Module:UserLinks]].
local snippets = mUserLinks.getSnippets(args)
local links = mUserLinks.getLinks(snippets)
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu