mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-12-24 17:10:29 +00:00
Optimise getStateQualifier()
Another fix for #1864, this time we’re caching state qualifiers as they are expensive to compute.
This commit is contained in:
parent
c6e48ebc2d
commit
848a7f4e74
@ -195,16 +195,23 @@ Widget.prototype.hasVariable = function(name,value) {
|
|||||||
Construct a qualifying string based on a hash of concatenating the values of a given variable in the parent chain
|
Construct a qualifying string based on a hash of concatenating the values of a given variable in the parent chain
|
||||||
*/
|
*/
|
||||||
Widget.prototype.getStateQualifier = function(name) {
|
Widget.prototype.getStateQualifier = function(name) {
|
||||||
|
this.qualifiers = this.qualifiers || Object.create(null);
|
||||||
name = name || "transclusion";
|
name = name || "transclusion";
|
||||||
var output = [],
|
if(this.qualifiers[name]) {
|
||||||
node = this;
|
return this.qualifiers[name];
|
||||||
while(node && node.parentWidget) {
|
} else {
|
||||||
if($tw.utils.hop(node.parentWidget.variables,name)) {
|
var output = [],
|
||||||
output.push(node.getVariable(name));
|
node = this;
|
||||||
|
while(node && node.parentWidget) {
|
||||||
|
if($tw.utils.hop(node.parentWidget.variables,name)) {
|
||||||
|
output.push(node.getVariable(name));
|
||||||
|
}
|
||||||
|
node = node.parentWidget;
|
||||||
}
|
}
|
||||||
node = node.parentWidget;
|
var value = $tw.utils.hashString(output.join(""));
|
||||||
|
this.qualifiers[name] = value;
|
||||||
|
return value;
|
||||||
}
|
}
|
||||||
return $tw.utils.hashString(output.join(""));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user