mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 10:07:19 +00:00
Optimise variable prototype chain handling
With this improvement and 53d229592d
I'm measuring a 10-15% performance improvement between v5.2.3 and master using https://github.com/Jermolene/tiddlywiki-performance-test-rig
This commit is contained in:
parent
0a00da6db9
commit
81ac987484
@ -39,7 +39,10 @@ Compute the internal state of the widget
|
|||||||
ImportVariablesWidget.prototype.execute = function(tiddlerList) {
|
ImportVariablesWidget.prototype.execute = function(tiddlerList) {
|
||||||
var widgetPointer = this;
|
var widgetPointer = this;
|
||||||
// Got to flush all the accumulated variables
|
// Got to flush all the accumulated variables
|
||||||
this.variables = new this.variablesConstructor();
|
this.variables = Object.create(null);
|
||||||
|
if(this.parentWidget) {
|
||||||
|
Object.setPrototypeOf(this.variables,this.parentWidget.variables);
|
||||||
|
}
|
||||||
// Get our parameters
|
// Get our parameters
|
||||||
this.filter = this.getAttribute("filter");
|
this.filter = this.getAttribute("filter");
|
||||||
// Compute the filter
|
// Compute the filter
|
||||||
|
@ -38,9 +38,10 @@ Widget.prototype.initialise = function(parseTreeNode,options) {
|
|||||||
this.parseTreeNode = parseTreeNode;
|
this.parseTreeNode = parseTreeNode;
|
||||||
this.wiki = options.wiki;
|
this.wiki = options.wiki;
|
||||||
this.parentWidget = options.parentWidget;
|
this.parentWidget = options.parentWidget;
|
||||||
this.variablesConstructor = function() {};
|
this.variables = Object.create(null);
|
||||||
this.variablesConstructor.prototype = this.parentWidget ? this.parentWidget.variables : {};
|
if(this.parentWidget) {
|
||||||
this.variables = new this.variablesConstructor();
|
Object.setPrototypeOf(this.variables,this.parentWidget.variables);
|
||||||
|
}
|
||||||
this.document = options.document;
|
this.document = options.document;
|
||||||
this.attributes = {};
|
this.attributes = {};
|
||||||
this.children = [];
|
this.children = [];
|
||||||
|
Loading…
Reference in New Issue
Block a user