Jump to content

Mòideal:User/doc

O Wiktionary

This is the documentation page for Mòideal:User

(deasbaireachd⧼tpt-languages-separator⧽deasaich⧼tpt-languages-separator⧽eachdraidh⧼tpt-languages-separator⧽ceanglaichean⧼tpt-languages-separator⧽doc⧼tpt-languages-separator⧽bogsa-gainmhich⧼tpt-languages-separator⧽cùisean deuchainn)

This module implements {{User}}. For documentation, please see the template page.

Mion-fhiosrachadh teicnigeach - Technical details

While the {{User}} template is only a wrapper for Mòideal:UserLinks, by implementing it as a Lua module we make significant gains in performance. It is roughly twice as fast as accessing Mòideal:UserLinks from wikitext. For example, this module rendered a test page containing nothing but 1000 {{User}} transclusions in 3.9 seconds, whereas the version that called Mòideal:UserLinks from wikitext rendered it in 7.7 seconds.

The performance gains are achieved by reducing the number of parameters that are looked up from wikitext. In particular, the link codes, "t" and "c", along with the "span=no" option, are passed directly to UserLinks. Also, UserLinks looks up the arguments "user", "User", "project", "Project", "lang", and "Lang". From wikitext, each parameter is checked twice – once for the #invoke text and once for the calling template – and each check is relatively resource-heavy. From Lua, each parameter is only checked once, and the individual checks take much less time. This means that on average, maybe nine argument lookups are saved in each invocation by using this module. On pages with hundreds or thousands of invocations, this adds up to a lot of argument lookups saved.