summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpaulirish <paulirish@chromium.org>2016-03-18 15:47:09 -0700
committerCommit bot <commit-bot@chromium.org>2016-03-18 22:50:26 +0000
commit71dc302acd0500bc6a0aec027b8f543eb6b433b3 (patch)
tree5769047c759cf899a36b73513ae61652487fd132
parent6477fbded94522e26875bbf405710060d01ea971 (diff)
downloadchromium_src-71dc302acd0500bc6a0aec027b8f543eb6b433b3.zip
chromium_src-71dc302acd0500bc6a0aec027b8f543eb6b433b3.tar.gz
chromium_src-71dc302acd0500bc6a0aec027b8f543eb6b433b3.tar.bz2
DevTools: remove insertionIndexForObjectInListSortedByFunction
Review URL: https://codereview.chromium.org/1817603003 Cr-Commit-Position: refs/heads/master@{#382116}
-rw-r--r--third_party/WebKit/Source/devtools/front_end/audits/AuditLauncherView.js2
-rw-r--r--third_party/WebKit/Source/devtools/front_end/components/ExecutionContextModel.js2
-rw-r--r--third_party/WebKit/Source/devtools/front_end/console/ConsoleView.js2
-rw-r--r--third_party/WebKit/Source/devtools/front_end/platform/utilities.js17
-rw-r--r--third_party/WebKit/Source/devtools/front_end/source_frame/SourceFrame.js4
-rw-r--r--third_party/WebKit/Source/devtools/front_end/timeline/TimelineFrameModel.js4
-rw-r--r--third_party/WebKit/Source/devtools/front_end/timeline/TimelineModel.js6
-rw-r--r--third_party/WebKit/Source/devtools/front_end/timeline/TimelineUIUtils.js2
-rw-r--r--third_party/WebKit/Source/devtools/front_end/ui/treeoutline.js2
-rw-r--r--third_party/WebKit/Source/devtools/front_end/ui_lazy/FilteredListWidget.js2
10 files changed, 13 insertions, 30 deletions
diff --git a/third_party/WebKit/Source/devtools/front_end/audits/AuditLauncherView.js b/third_party/WebKit/Source/devtools/front_end/audits/AuditLauncherView.js
index e67375d..59bc4fd 100644
--- a/third_party/WebKit/Source/devtools/front_end/audits/AuditLauncherView.js
+++ b/third_party/WebKit/Source/devtools/front_end/audits/AuditLauncherView.js
@@ -124,7 +124,7 @@ WebInspector.AuditLauncherView.prototype = {
var bTitle = b.displayName || "";
return aTitle.localeCompare(bTitle);
}
- var insertBefore = insertionIndexForObjectInListSortedByFunction(category, this._sortedCategories, compareCategories);
+ var insertBefore = this._sortedCategories.lowerBound(category, compareCategories);
this._categoriesElement.insertBefore(categoryElement, this._categoriesElement.children[insertBefore]);
this._sortedCategories.splice(insertBefore, 0, category);
this._selectedCategoriesUpdated();
diff --git a/third_party/WebKit/Source/devtools/front_end/components/ExecutionContextModel.js b/third_party/WebKit/Source/devtools/front_end/components/ExecutionContextModel.js
index 3008bd9..d4c0e0c 100644
--- a/third_party/WebKit/Source/devtools/front_end/components/ExecutionContextModel.js
+++ b/third_party/WebKit/Source/devtools/front_end/components/ExecutionContextModel.js
@@ -65,7 +65,7 @@ WebInspector.ExecutionContextModel.prototype = {
this._optionByExecutionContext.set(executionContext, newOption);
var options = this._selectElement.options;
var contexts = Array.prototype.map.call(options, mapping);
- var index = insertionIndexForObjectInListSortedByFunction(executionContext, contexts, WebInspector.ExecutionContext.comparator);
+ var index = contexts.lowerBound(executionContext, WebInspector.ExecutionContext.comparator)
this._selectElement.insertBefore(newOption, options[index]);
if (executionContext === WebInspector.context.flavor(WebInspector.ExecutionContext))
diff --git a/third_party/WebKit/Source/devtools/front_end/console/ConsoleView.js b/third_party/WebKit/Source/devtools/front_end/console/ConsoleView.js
index bee8c32..da86d91 100644
--- a/third_party/WebKit/Source/devtools/front_end/console/ConsoleView.js
+++ b/third_party/WebKit/Source/devtools/front_end/console/ConsoleView.js
@@ -427,7 +427,7 @@ WebInspector.ConsoleView.prototype = {
message.timestamp = this._consoleMessages.length ? this._consoleMessages.peekLast().consoleMessage().timestamp : 0;
var viewMessage = this._createViewMessage(message);
message[this._viewMessageSymbol] = viewMessage;
- var insertAt = insertionIndexForObjectInListSortedByFunction(viewMessage, this._consoleMessages, compareTimestamps, true);
+ var insertAt = this._consoleMessages.upperBound(viewMessage, compareTimestamps)
var insertedInMiddle = insertAt < this._consoleMessages.length;
this._consoleMessages.splice(insertAt, 0, viewMessage);
diff --git a/third_party/WebKit/Source/devtools/front_end/platform/utilities.js b/third_party/WebKit/Source/devtools/front_end/platform/utilities.js
index bdd4112..a4a1332 100644
--- a/third_party/WebKit/Source/devtools/front_end/platform/utilities.js
+++ b/third_party/WebKit/Source/devtools/front_end/platform/utilities.js
@@ -931,23 +931,6 @@ Object.defineProperty(Array.prototype, "mergeOrdered",
}());
-
-/**
- * @param {!T} object
- * @param {!Array.<!S>} list
- * @param {function(!T,!S):number=} comparator
- * @param {boolean=} insertionIndexAfter
- * @return {number}
- * @template T,S
- */
-function insertionIndexForObjectInListSortedByFunction(object, list, comparator, insertionIndexAfter)
-{
- if (insertionIndexAfter)
- return list.upperBound(object, comparator);
- else
- return list.lowerBound(object, comparator);
-}
-
/**
* @param {string} format
* @param {...*} var_arg
diff --git a/third_party/WebKit/Source/devtools/front_end/source_frame/SourceFrame.js b/third_party/WebKit/Source/devtools/front_end/source_frame/SourceFrame.js
index 876a93a..f59378c 100644
--- a/third_party/WebKit/Source/devtools/front_end/source_frame/SourceFrame.js
+++ b/third_party/WebKit/Source/devtools/front_end/source_frame/SourceFrame.js
@@ -405,7 +405,7 @@ WebInspector.SourceFrame.prototype = {
*/
_searchResultIndexForCurrentSelection: function()
{
- return insertionIndexForObjectInListSortedByFunction(this._textEditor.selection().collapseToEnd(), this._searchResults, WebInspector.TextRange.comparator);
+ return this._searchResults.lowerBound(this._textEditor.selection().collapseToEnd(), WebInspector.TextRange.comparator);
},
jumpToNextSearchResult: function()
@@ -483,7 +483,7 @@ WebInspector.SourceFrame.prototype = {
return;
// Calculate the position of the end of the last range to be edited.
- var currentRangeIndex = insertionIndexForObjectInListSortedByFunction(this._textEditor.selection(), ranges, WebInspector.TextRange.comparator);
+ var currentRangeIndex = ranges.lowerBound(this._textEditor.selection(), WebInspector.TextRange.comparator);
var lastRangeIndex = mod(currentRangeIndex - 1, ranges.length);
var lastRange = ranges[lastRangeIndex];
var replacementLineEndings = replacement.computeLineEndings();
diff --git a/third_party/WebKit/Source/devtools/front_end/timeline/TimelineFrameModel.js b/third_party/WebKit/Source/devtools/front_end/timeline/TimelineFrameModel.js
index f4fcb9c..c51db5c 100644
--- a/third_party/WebKit/Source/devtools/front_end/timeline/TimelineFrameModel.js
+++ b/third_party/WebKit/Source/devtools/front_end/timeline/TimelineFrameModel.js
@@ -71,8 +71,8 @@ WebInspector.TimelineFrameModelBase.prototype = {
return value - object.endTime;
}
var frames = this._frames;
- var firstFrame = insertionIndexForObjectInListSortedByFunction(startTime, frames, compareEndTime);
- var lastFrame = insertionIndexForObjectInListSortedByFunction(endTime, frames, compareStartTime);
+ var firstFrame = frames.lowerBound(startTime, compareEndTime);
+ var lastFrame = frames.lowerBound(endTime, compareStartTime);
return frames.slice(firstFrame, lastFrame);
},
diff --git a/third_party/WebKit/Source/devtools/front_end/timeline/TimelineModel.js b/third_party/WebKit/Source/devtools/front_end/timeline/TimelineModel.js
index d8a5b98..88edc1f 100644
--- a/third_party/WebKit/Source/devtools/front_end/timeline/TimelineModel.js
+++ b/third_party/WebKit/Source/devtools/front_end/timeline/TimelineModel.js
@@ -593,15 +593,15 @@ WebInspector.TimelineModel.prototype = {
// First Paint is actually a DrawFrame that happened after first CompositeLayers following last CommitLoadEvent.
var recordTypes = WebInspector.TimelineModel.RecordType;
- var i = insertionIndexForObjectInListSortedByFunction(this._firstCompositeLayers, this._inspectedTargetEvents, WebInspector.TracingModel.Event.compareStartTime);
+ var i = this._inspectedTargetEvents.lowerBound(this._firstCompositeLayers, WebInspector.TracingModel.Event.compareStartTime);
for (; i < this._inspectedTargetEvents.length && this._inspectedTargetEvents[i].name !== recordTypes.DrawFrame; ++i) { }
if (i >= this._inspectedTargetEvents.length)
return;
var drawFrameEvent = this._inspectedTargetEvents[i];
var firstPaintEvent = new WebInspector.TracingModel.Event(drawFrameEvent.categoriesString, recordTypes.MarkFirstPaint, WebInspector.TracingModel.Phase.Instant, drawFrameEvent.startTime, drawFrameEvent.thread);
- this._mainThreadEvents.splice(insertionIndexForObjectInListSortedByFunction(firstPaintEvent, this._mainThreadEvents, WebInspector.TracingModel.Event.compareStartTime), 0, firstPaintEvent);
+ this._mainThreadEvents.splice(this._mainThreadEvents.lowerBound(firstPaintEvent, WebInspector.TracingModel.Event.compareStartTime), 0, firstPaintEvent);
var firstPaintRecord = new WebInspector.TimelineModel.Record(firstPaintEvent);
- this._eventDividerRecords.splice(insertionIndexForObjectInListSortedByFunction(firstPaintRecord, this._eventDividerRecords, WebInspector.TimelineModel.Record._compareStartTime), 0, firstPaintRecord);
+ this._eventDividerRecords.splice(this._eventDividerRecords.lowerBound(firstPaintRecord, WebInspector.TimelineModel.Record._compareStartTime), 0, firstPaintRecord);
},
/**
diff --git a/third_party/WebKit/Source/devtools/front_end/timeline/TimelineUIUtils.js b/third_party/WebKit/Source/devtools/front_end/timeline/TimelineUIUtils.js
index 2ef8553..d1a74d2 100644
--- a/third_party/WebKit/Source/devtools/front_end/timeline/TimelineUIUtils.js
+++ b/third_party/WebKit/Source/devtools/front_end/timeline/TimelineUIUtils.js
@@ -854,7 +854,7 @@ WebInspector.TimelineUIUtils.buildRangeStats = function(model, startTime, endTim
return value < task.endTime() ? -1 : 1;
}
var mainThreadTasks = model.mainThreadTasks();
- var taskIndex = insertionIndexForObjectInListSortedByFunction(startTime, mainThreadTasks, compareEndTime);
+ var taskIndex = mainThreadTasks.lowerBound(startTime, compareEndTime);
for (; taskIndex < mainThreadTasks.length; ++taskIndex) {
var task = mainThreadTasks[taskIndex];
if (task.startTime() > endTime)
diff --git a/third_party/WebKit/Source/devtools/front_end/ui/treeoutline.js b/third_party/WebKit/Source/devtools/front_end/ui/treeoutline.js
index 7755b1c..47c9b79 100644
--- a/third_party/WebKit/Source/devtools/front_end/ui/treeoutline.js
+++ b/third_party/WebKit/Source/devtools/front_end/ui/treeoutline.js
@@ -471,7 +471,7 @@ TreeElement.prototype = {
var insertionIndex;
if (this.treeOutline && this.treeOutline._comparator)
- insertionIndex = insertionIndexForObjectInListSortedByFunction(child, this._children, this.treeOutline._comparator);
+ insertionIndex = this._children.lowerBound(child, this.treeOutline._comparator);
else
insertionIndex = this._children.length;
this.insertChild(child, insertionIndex);
diff --git a/third_party/WebKit/Source/devtools/front_end/ui_lazy/FilteredListWidget.js b/third_party/WebKit/Source/devtools/front_end/ui_lazy/FilteredListWidget.js
index dae34a5..0c014fa 100644
--- a/third_party/WebKit/Source/devtools/front_end/ui_lazy/FilteredListWidget.js
+++ b/third_party/WebKit/Source/devtools/front_end/ui_lazy/FilteredListWidget.js
@@ -220,7 +220,7 @@ WebInspector.FilteredListWidget.prototype = {
// Find its index in the scores array (earlier elements have bigger scores).
if (score > minBestScore || bestScores.length < bestItemsToCollect) {
- var index = insertionIndexForObjectInListSortedByFunction(score, bestScores, compareIntegers, true);
+ var index = bestScores.upperBound(score, compareIntegers);
bestScores.splice(index, 0, score);
bestItems.splice(index, 0, i);
if (bestScores.length > bestItemsToCollect) {