From 5d3aaabc9af0ce38c3677f2ce8867c5f08880172 Mon Sep 17 00:00:00 2001 From: Lucas Wojciechowski Date: Tue, 23 Feb 2016 17:00:06 -0800 Subject: [PATCH] Performance optimize buffer parameters --- js/data/buffer.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/js/data/buffer.js b/js/data/buffer.js index 41741ece6ca..01670897a58 100644 --- a/js/data/buffer.js +++ b/js/data/buffer.js @@ -197,7 +197,7 @@ Buffer.prototype._createPushMethod = function() { body += 'var i = this.length++;\n'; body += 'var o = i * ' + this.itemSize + ';\n'; - body += 'if (o + ' + this.itemSize + ' > this.capacity) { this._resize(this.capacity * 1.5); }\n'; + body += 'if (o + ' + this.itemSize + ' > this.capacity) { this._resize(this.capacity * ' + Buffer.CAPACITY_RESIZE_MULTIPLE + '); }\n'; for (var i = 0; i < this.attributes.length; i++) { var attribute = this.attributes[i]; @@ -269,7 +269,14 @@ Buffer.ELEMENT_ATTRIBUTE_TYPE = Buffer.AttributeType.UNSIGNED_SHORT; * @private * @readonly */ -Buffer.CAPACITY_DEFAULT = 8192; +Buffer.CAPACITY_DEFAULT = 1024; + +/** + * @property {number} + * @private + * @readonly + */ +Buffer.CAPACITY_RESIZE_MULTIPLE = 5; /** * WebGL performs best if buffer sizes are aligned to 2 byte boundaries.