Skip to content

Commit

Permalink
Performance optimize buffer parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas Wojciechowski committed Feb 24, 2016
1 parent ebb018c commit 5d3aaab
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions js/data/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 5d3aaab

Please sign in to comment.