Skip to content

Commit

Permalink
don't realloc PriorityQHeap's vert list
Browse files Browse the repository at this point in the history
  • Loading branch information
brendankenny committed Oct 29, 2015
1 parent 0dfab79 commit 17e9238
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 81 deletions.
27 changes: 1 addition & 26 deletions libtess.cat.js
Original file line number Diff line number Diff line change
Expand Up @@ -4581,8 +4581,7 @@ libtess.PriorityQHeap = function(leq) {
* An unordered list of vertices in the heap, with null in empty slots.
* @private {!Array<libtess.PQKey>}
*/
this.verts_ = libtess.PriorityQHeap.reallocKeys_([],
libtess.PriorityQHeap.INIT_SIZE_ + 1);
this.verts_ = [null, null];

/**
* An unordered list of indices mapping vertex handles into the heap. An entry
Expand Down Expand Up @@ -4668,28 +4667,6 @@ libtess.PriorityQHeap.reallocNumeric_ = function(oldArray, size) {
return newArray;
};

/**
* Allocate a PQKey array of size size. oldArray's contents are copied to the
* beginning of the new array. The rest of the array is filled with null values.
* @private
* @param {!Array<libtess.PQKey>} oldArray
* @param {number} size
* @return {!Array<libtess.PQKey>}
*/
libtess.PriorityQHeap.reallocKeys_ = function(oldArray, size) {
var newArray = new Array(size);

for (var index = 0; index < oldArray.length; index++) {
newArray[index] = oldArray[index];
}

for (; index < size; index++) {
newArray[index] = null;
}

return newArray;
};

/**
* Initializing ordering of the heap. Must be called before any method other
* than insert is called to ensure correctness when removing or querying.
Expand Down Expand Up @@ -4717,8 +4694,6 @@ libtess.PriorityQHeap.prototype.insert = function(keyNew) {

this.heap_ = libtess.PriorityQHeap.reallocNumeric_(this.heap_,
this.max_ + 1);
this.verts_ = libtess.PriorityQHeap.reallocKeys_(this.verts_,
this.max_ + 1);
this.handles_ = libtess.PriorityQHeap.reallocNumeric_(this.handles_,
this.max_ + 1);
}
Expand Down
27 changes: 1 addition & 26 deletions libtess.debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -4651,8 +4651,7 @@ libtess.PriorityQHeap = function(leq) {
* An unordered list of vertices in the heap, with null in empty slots.
* @private {!Array<libtess.PQKey>}
*/
this.verts_ = libtess.PriorityQHeap.reallocKeys_([],
libtess.PriorityQHeap.INIT_SIZE_ + 1);
this.verts_ = [null, null];

/**
* An unordered list of indices mapping vertex handles into the heap. An entry
Expand Down Expand Up @@ -4738,28 +4737,6 @@ libtess.PriorityQHeap.reallocNumeric_ = function(oldArray, size) {
return newArray;
};

/**
* Allocate a PQKey array of size size. oldArray's contents are copied to the
* beginning of the new array. The rest of the array is filled with null values.
* @private
* @param {!Array<libtess.PQKey>} oldArray
* @param {number} size
* @return {!Array<libtess.PQKey>}
*/
libtess.PriorityQHeap.reallocKeys_ = function(oldArray, size) {
var newArray = new Array(size);

for (var index = 0; index < oldArray.length; index++) {
newArray[index] = oldArray[index];
}

for (; index < size; index++) {
newArray[index] = null;
}

return newArray;
};

/**
* Initializing ordering of the heap. Must be called before any method other
* than insert is called to ensure correctness when removing or querying.
Expand Down Expand Up @@ -4787,8 +4764,6 @@ libtess.PriorityQHeap.prototype.insert = function(keyNew) {

this.heap_ = libtess.PriorityQHeap.reallocNumeric_(this.heap_,
this.max_ + 1);
this.verts_ = libtess.PriorityQHeap.reallocKeys_(this.verts_,
this.max_ + 1);
this.handles_ = libtess.PriorityQHeap.reallocNumeric_(this.handles_,
this.max_ + 1);
}
Expand Down
6 changes: 3 additions & 3 deletions libtess.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 1 addition & 26 deletions src/priorityq/PriorityQHeap.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ libtess.PriorityQHeap = function(leq) {
* An unordered list of vertices in the heap, with null in empty slots.
* @private {!Array<libtess.PQKey>}
*/
this.verts_ = libtess.PriorityQHeap.reallocKeys_([],
libtess.PriorityQHeap.INIT_SIZE_ + 1);
this.verts_ = [null, null];

/**
* An unordered list of indices mapping vertex handles into the heap. An entry
Expand Down Expand Up @@ -138,28 +137,6 @@ libtess.PriorityQHeap.reallocNumeric_ = function(oldArray, size) {
return newArray;
};

/**
* Allocate a PQKey array of size size. oldArray's contents are copied to the
* beginning of the new array. The rest of the array is filled with null values.
* @private
* @param {!Array<libtess.PQKey>} oldArray
* @param {number} size
* @return {!Array<libtess.PQKey>}
*/
libtess.PriorityQHeap.reallocKeys_ = function(oldArray, size) {
var newArray = new Array(size);

for (var index = 0; index < oldArray.length; index++) {
newArray[index] = oldArray[index];
}

for (; index < size; index++) {
newArray[index] = null;
}

return newArray;
};

/**
* Initializing ordering of the heap. Must be called before any method other
* than insert is called to ensure correctness when removing or querying.
Expand Down Expand Up @@ -187,8 +164,6 @@ libtess.PriorityQHeap.prototype.insert = function(keyNew) {

this.heap_ = libtess.PriorityQHeap.reallocNumeric_(this.heap_,
this.max_ + 1);
this.verts_ = libtess.PriorityQHeap.reallocKeys_(this.verts_,
this.max_ + 1);
this.handles_ = libtess.PriorityQHeap.reallocNumeric_(this.handles_,
this.max_ + 1);
}
Expand Down

0 comments on commit 17e9238

Please sign in to comment.