Saltar al contento

Module talk:Wikidata

Le contento del pagina non es supportate in altere linguas.
De Wikipedia, le encyclopedia libere
Version del 20:25, 8 martio 2018 per Amir Sarabadani (WMDE) (discussion | contributiones) (Pagina create con '== Critical performance improvement == There is the following inefficiency in Wikidata module: <syntaxhighlight lang="lua"> -- otherwise, iterate over all properties, fetch...')
(diff) ← Version precedente | Version actual (diff) | Version sequente → (diff)

Critical performance improvement

There is the following inefficiency in Wikidata module:

		-- otherwise, iterate over all properties, fetch their labels and compare this to the given property name
		for k, v in pairs(entity.claims) do
			if mw.wikibase.label(k) == property then return v end
		end

This can also be expressed with:

		property = mw.wikibase.resolvePropertyId(property)
		if not property then return end

		return entity.claims[property]

The advantaged of the second version is that it doesn't need to iterate over all Statements (which is badly discouraged), thus the pages in question don't "use" all Statements. See also T178114. Please fix this problem. Thank you! Amir Sarabadani (WMDE) (discussion) 20:25, 8 martio 2018 (UTC)[responder]