Chromium Code Reviews| Index: Source/devtools/front_end/components_lazy/FilmStripModel.js |
| diff --git a/Source/devtools/front_end/components_lazy/FilmStripModel.js b/Source/devtools/front_end/components_lazy/FilmStripModel.js |
| index 55d25b7e44f6f343aec957bd3f37d67e33488130..dc517a6f7cfadf4838c743909f1a8fa56acce17a 100644 |
| --- a/Source/devtools/front_end/components_lazy/FilmStripModel.js |
| +++ b/Source/devtools/front_end/components_lazy/FilmStripModel.js |
| @@ -54,20 +54,19 @@ WebInspector.FilmStripModel.prototype = { |
| * @param {number} timestamp |
| * @return {?WebInspector.FilmStripModel.Frame} |
| */ |
| - firstFrameAfterCommit: function(timestamp) |
| + frameByTimestamp: function(timestamp) |
| { |
| - var bestIndex = 0; |
| - var bestDelta = Number.MAX_VALUE; |
| - for (var i = 0; i < this._frames.length; ++i) { |
| - var delta = this._frames[i].timestamp - timestamp; |
| - if (delta < 0) |
| - continue; |
| - if (delta < bestDelta) { |
| - bestIndex = i; |
| - bestDelta = delta; |
| - } |
| + /** |
| + * @param {number} timestamp |
| + * @param {!WebInspector.FilmStripModel.Frame} frame |
| + * @return {number} |
| + */ |
| + function comparator(timestamp, frame) |
| + { |
| + return timestamp - frame.timestamp; |
| } |
| - return bestDelta < 10 ? this._frames[bestIndex] : null; |
| + var index = this._frames.upperBound(timestamp, comparator) - 1; |
|
yurys
2015/06/09 13:22:36
lowerBound?
alph
2015/06/09 13:26:38
Done.
|
| + return index >= 0 ? this._frames[index] : null; |
| } |
| } |