1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-23 18:17:20 +00:00

Preallocating in LinkedList's toArray method (#5488)

This commit is contained in:
Cameron Fischer 2021-02-11 08:39:50 -05:00 committed by GitHub
parent bfa062f23d
commit c0dc2669c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -89,8 +89,9 @@ LinkedList.prototype.each = function(callback) {
}; };
LinkedList.prototype.toArray = function() { LinkedList.prototype.toArray = function() {
var output = []; var output = new Array(this.length),
this.each(function(value) { output.push(value); }); index = 0;
this.each(function(value) { output[index++] = value; });
return output; return output;
}; };