1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-06-16 10:29:54 +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() {
var output = [];
this.each(function(value) { output.push(value); });
var output = new Array(this.length),
index = 0;
this.each(function(value) { output[index++] = value; });
return output;
};