Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(689)

Side by Side Diff: Source/devtools/front_end/MemoryStatistics.js

Issue 18828002: DevTools: Replace binarySearch with lowerBound and upperBound functions (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebaseline Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/devtools/front_end/DefaultTextEditor.js ('k') | Source/devtools/front_end/externs.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 257
258 _calculateVisibleIndexes: function() 258 _calculateVisibleIndexes: function()
259 { 259 {
260 var calculator = this._timelinePanel.calculator; 260 var calculator = this._timelinePanel.calculator;
261 var start = calculator.minimumBoundary() * 1000; 261 var start = calculator.minimumBoundary() * 1000;
262 var end = calculator.maximumBoundary() * 1000; 262 var end = calculator.maximumBoundary() * 1000;
263 function comparator(value, sample) 263 function comparator(value, sample)
264 { 264 {
265 return value - sample.time; 265 return value - sample.time;
266 } 266 }
267 var firstIndex = binarySearch(start, this._counters, comparator);
268 var lastIndex = binarySearch(end, this._counters, comparator);
269 if (firstIndex < 0)
270 firstIndex = Math.max(0, -firstIndex - 2);
271 if (lastIndex < 0)
272 lastIndex = Math.min(-lastIndex - 1, this._counters.length - 1);
273 267
274 // Maximum index of element whose time <= start. 268 // Maximum index of element whose time <= start.
275 this._minimumIndex = firstIndex; 269 this._minimumIndex = Number.constrain(this._counters.upperBound(start, c omparator) - 1, 0, this._counters.length - 1);
276 270
277 // Minimum index of element whose time >= end. 271 // Minimum index of element whose time >= end.
278 this._maximumIndex = lastIndex; 272 this._maximumIndex = Number.constrain(this._counters.lowerBound(end, com parator), 0, this._counters.length - 1);
279 273
280 // Current window bounds. 274 // Current window bounds.
281 this._minTime = start; 275 this._minTime = start;
282 this._maxTime = end; 276 this._maxTime = end;
283 }, 277 },
284 278
285 /** 279 /**
286 * @param {MouseEvent} event 280 * @param {MouseEvent} event
287 */ 281 */
288 _onClick: function(event) 282 _onClick: function(event)
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height); 433 ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
440 this._discardImageUnderMarker(); 434 this._discardImageUnderMarker();
441 }, 435 },
442 436
443 _discardImageUnderMarker: function() 437 _discardImageUnderMarker: function()
444 { 438 {
445 throw new Error("Not implemented"); 439 throw new Error("Not implemented");
446 } 440 }
447 } 441 }
448 442
OLDNEW
« no previous file with comments | « Source/devtools/front_end/DefaultTextEditor.js ('k') | Source/devtools/front_end/externs.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698