Skip to content

Commit

Permalink
Merge pull request #100 from CAFxX/patch-1
Browse files Browse the repository at this point in the history
Optimize PriorityQueue.js
  • Loading branch information
aphyr committed Aug 14, 2015
2 parents 30ec073 + 07ef0d6 commit c031516
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/riemann/dash/public/vendor/PriorityQueue.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
* @author Augusto Pascutti
*/
var QueueItem = function(v, p) {
this.value = v;
this.priority = p;
this.value = v;
this.priority = p;
this.value_JSON = JSON.stringify(v);
};

/**
Expand Down Expand Up @@ -64,8 +65,9 @@ PriorityQueue.prototype = {
known = false;
idx = 0;

var value_JSON = JSON.stringify(value);
this._queue.forEach(function() {
if (JSON.stringify(this._queue[idx].value) === JSON.stringify(value)) {
if (this._queue[idx].value_JSON === value_JSON) {
this._queue[idx].priority = priority;
known = true;
return;
Expand Down

0 comments on commit c031516

Please sign in to comment.