Module:Wd: Difference between revisions

Content deleted Content added
Added option to use multiple qualifier(s) commands, and fixed issue with references
Improved performance
Line 1,074:
return true
end
 
-- sorts the claims based on ranks, which is done to increase performance in certain cases;
-- e.g. with flags "normal+|best" given and claims stored in order "normal, normal, preferred",
-- then the "normal" claims would be fully processed first while the "preferred" one might be the only one returned;
-- after sorting, this would be "preferred, normal, normal" and the "normal" claims won't be processed
function Config:sortOnRanks(claims)
local rankPos
local ranks = {{}, {}, {}} -- preferred, normal, deprecated
local sorted = {}
for i, v in ipairs(claims) do
rankPos = convertRank(v.rank)
ranks[rankPos][#ranks[rankPos] + 1] = v
end
sorted = ranks[1]
sorted = mergeTables(sorted, ranks[2])
sorted = mergeTables(sorted, ranks[3])
return sorted
end
 
Line 1,755 ⟶ 1,776:
if _.entity and _.entity.claims then claims = _.entity.claims[_.propertyID] end
if claims then
-- iteratefirst throughsort the claims toon collectranks valuesfor better performance
claims = _:sortOnRanks(claims)
-- then iterate through the claims to collect values
return concatValues(_.states[parameters.property]:iterate(claims, hooks, State.claimMatches)) -- pass property State with level 1 hooks and matchHook
else