round instead of floor

pull/7/head
yann300 8 years ago
parent d0f0bd0571
commit 3bad42cef5
  1. 14
      src/helpers/util.js
  2. 2
      src/ui/StepManager.js

@ -85,6 +85,20 @@ module.exports = {
return index >= 0 ? array[index] : null
},
/*
Binary Search:
Assumes that @arg array is sorted increasingly
return (saying middle=(array[i] + array[i + 1]) / 2 <= target) return i if target < middle; return i + 1 if target >= middle; return array.length - 1 if index > array.length; return null if array[0] > target || array is empty
*/
findLowerClosestBound: function (target, array) {
var index = this.findLowerBound(target, array)
if (index > array.length) {
return index
}
var middle = (array[index] + array[index + 1]) / 2
return target >= middle ? index + 1 : index
},
/**
* Find the call from @args rootCall which contains @args index (recursive)
*

@ -64,7 +64,7 @@ function StepManager (_parent, _traceManager) {
StepManager.prototype.resolveToReducedTrace = function (value, incr) {
if (this.parent.callTree.reducedTrace.length) {
var nextSource = utils.findLowerBound(value, this.parent.callTree.reducedTrace)
var nextSource = utils.findLowerClosestBound(value, this.parent.callTree.reducedTrace)
nextSource = nextSource < this.parent.callTree.reducedTrace.length - 1 ? nextSource + incr : nextSource
return this.parent.callTree.reducedTrace[nextSource]
}

Loading…
Cancel
Save