mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-08 20:58:24 +08:00
Inline and remove peekLast()
In the future we can use `.at()`, but that has not been shipped yet. R=szuend@chromium.org Bug: 1050549 Change-Id: I89e760db277ffb91bfbba93106e6e11d3ece91d6 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2624711 Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org> Reviewed-by: Simon Zünd <szuend@chromium.org> Auto-Submit: Tim van der Lippe <tvanderlippe@chromium.org>
This commit is contained in:
committed by
Commit Bot
parent
bcd6b5c3ff
commit
779b46bac3
@@ -367,7 +367,7 @@ class Binding {
|
||||
* @param {!Protocol.Page.FrameId} frameId
|
||||
*/
|
||||
_recreateUISourceCodeIfNeeded(frameId) {
|
||||
const sourceMap = this._referringSourceMaps.peekLast();
|
||||
const sourceMap = this._referringSourceMaps[this._referringSourceMaps.length - 1];
|
||||
if (!sourceMap || this._activeSourceMap === sourceMap) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ BindingsTestRunner.TestFileSystem.prototype = {
|
||||
const pathTokens = path.split('/');
|
||||
let node = this.root;
|
||||
const folders = pathTokens.slice(0, pathTokens.length - 1);
|
||||
const fileName = pathTokens.peekLast();
|
||||
const fileName = pathTokens[pathTokens.length - 1];
|
||||
|
||||
for (const folder of folders) {
|
||||
let dir = node._children.get(folder);
|
||||
|
||||
@@ -665,7 +665,7 @@ export class ConsoleView extends UI.Widget.VBox {
|
||||
const viewMessage = this._createViewMessage(message);
|
||||
consoleMessageToViewMessage.set(message, viewMessage);
|
||||
if (message.type === SDK.ConsoleModel.MessageType.Command || message.type === SDK.ConsoleModel.MessageType.Result) {
|
||||
const lastMessage = this._consoleMessages.peekLast();
|
||||
const lastMessage = this._consoleMessages[this._consoleMessages.length - 1];
|
||||
const newTimestamp = lastMessage && messagesSortedBySymbol.get(lastMessage) || 0;
|
||||
messagesSortedBySymbol.set(viewMessage, newTimestamp);
|
||||
} else {
|
||||
@@ -771,11 +771,12 @@ export class ConsoleView extends UI.Widget.VBox {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!preventCollapse && this._tryToCollapseMessages(viewMessage, this._visibleViewMessages.peekLast())) {
|
||||
if (!preventCollapse &&
|
||||
this._tryToCollapseMessages(viewMessage, this._visibleViewMessages[this._visibleViewMessages.length - 1])) {
|
||||
return;
|
||||
}
|
||||
|
||||
const lastMessage = this._visibleViewMessages.peekLast();
|
||||
const lastMessage = this._visibleViewMessages[this._visibleViewMessages.length - 1];
|
||||
if (viewMessage.consoleMessage().type === SDK.ConsoleModel.MessageType.EndGroup) {
|
||||
if (lastMessage && !this._currentGroup.messagesHidden()) {
|
||||
lastMessage.incrementCloseGroupDecorationCount();
|
||||
@@ -1069,7 +1070,8 @@ export class ConsoleView extends UI.Widget.VBox {
|
||||
this._appendMessageToEnd(startGroupViewMessage);
|
||||
|
||||
for (const viewMessageInGroup of viewMessagesInGroup) {
|
||||
viewMessageInGroup.setInSimilarGroup(true, viewMessagesInGroup.peekLast() === viewMessageInGroup);
|
||||
viewMessageInGroup.setInSimilarGroup(
|
||||
true, viewMessagesInGroup[viewMessagesInGroup.length - 1] === viewMessageInGroup);
|
||||
this._appendMessageToEnd(viewMessageInGroup, true);
|
||||
alreadyAdded.add(viewMessageInGroup.consoleMessage());
|
||||
}
|
||||
|
||||
@@ -478,11 +478,11 @@ export class CoverageModel extends SDK.SDKModel.SDKModel {
|
||||
const result = [];
|
||||
const stack = [];
|
||||
for (const entry of ranges) {
|
||||
let top = stack.peekLast();
|
||||
let top = stack[stack.length - 1];
|
||||
while (top && top.endOffset <= entry.startOffset) {
|
||||
append(top.endOffset, top.count);
|
||||
stack.pop();
|
||||
top = stack.peekLast();
|
||||
top = stack[stack.length - 1];
|
||||
}
|
||||
append(entry.startOffset, top ? top.count : 0);
|
||||
stack.push(entry);
|
||||
@@ -497,7 +497,7 @@ export class CoverageModel extends SDK.SDKModel.SDKModel {
|
||||
* @param {number} count
|
||||
*/
|
||||
function append(end, count) {
|
||||
const last = result.peekLast();
|
||||
const last = result[result.length - 1];
|
||||
if (last) {
|
||||
if (last.end === end) {
|
||||
return;
|
||||
@@ -548,7 +548,7 @@ export class CoverageModel extends SDK.SDKModel.SDKModel {
|
||||
const coverageInfo = urlCoverage._ensureEntry(contentProvider, contentLength, startLine, startColumn, type);
|
||||
this._coverageByContentProvider.set(contentProvider, coverageInfo);
|
||||
const segments = CoverageModel._convertToDisjointSegments(ranges, stamp);
|
||||
const last = segments.peekLast();
|
||||
const last = segments[segments.length - 1];
|
||||
if (last && last.end < contentLength) {
|
||||
segments.push({end: contentLength, stamp: stamp, count: 0});
|
||||
}
|
||||
@@ -809,7 +809,7 @@ export const mergeSegments = (segmentsA, segmentsB) => {
|
||||
const b = segmentsB[indexB];
|
||||
const count = (a.count || 0) + (b.count || 0);
|
||||
const end = Math.min(a.end, b.end);
|
||||
const last = result.peekLast();
|
||||
const last = result[result.length - 1];
|
||||
const stamp = Math.min(a.stamp, b.stamp);
|
||||
if (!last || last.count !== count || last.stamp !== stamp) {
|
||||
result.push({end: end, count: count, stamp: stamp});
|
||||
|
||||
@@ -761,7 +761,7 @@ export class StylesSidebarPane extends ElementsSidebarPane {
|
||||
blocks.push(block);
|
||||
}
|
||||
|
||||
const lastBlock = blocks.peekLast();
|
||||
const lastBlock = blocks[blocks.length - 1];
|
||||
if (lastBlock) {
|
||||
this._idleCallbackManager.schedule(() => {
|
||||
const section = new StylePropertiesSection(this, matchedStyles, style);
|
||||
@@ -2451,7 +2451,7 @@ export class BlankStylePropertiesSection extends StylePropertiesSection {
|
||||
_actualRuleLocation() {
|
||||
const prefix = this._rulePrefix();
|
||||
const lines = prefix.split('\n');
|
||||
const lastLine = lines.peekLast();
|
||||
const lastLine = lines[lines.length - 1];
|
||||
const editRange = new TextUtils.TextRange.TextRange(0, 0, lines.length - 1, lastLine ? lastLine.length : 0);
|
||||
return this._ruleLocation.rebaseAfterTextEdit(TextUtils.TextRange.TextRange.createFromLocation(0, 0), editRange);
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ export class MediaQueryInspector extends UI.Widget.Widget {
|
||||
_squashAdjacentEqual(models) {
|
||||
const filtered = [];
|
||||
for (let i = 0; i < models.length; ++i) {
|
||||
const last = filtered.peekLast();
|
||||
const last = filtered[filtered.length - 1];
|
||||
if (!last || !last.equals(models[i])) {
|
||||
filtered.push(models[i]);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ export class FormattedContentBuilder {
|
||||
}
|
||||
|
||||
addToken(token: string, offset: number): void {
|
||||
const last = this.formattedContent.peekLast();
|
||||
const last = this.formattedContent[this.formattedContent.length - 1];
|
||||
if (this.enforceSpaceBetweenWords && last && /\w/.test(last[last.length - 1]) && /\w/.test(token)) {
|
||||
this.addSoftSpace();
|
||||
}
|
||||
|
||||
@@ -253,7 +253,7 @@ export class HTMLModel {
|
||||
if (lastOffset >= text.length) {
|
||||
break;
|
||||
}
|
||||
const element = this._stack.peekLast();
|
||||
const element = this._stack[this._stack.length - 1];
|
||||
if (!element) {
|
||||
break;
|
||||
}
|
||||
@@ -274,7 +274,7 @@ export class HTMLModel {
|
||||
}
|
||||
|
||||
while (this._stack.length > 1) {
|
||||
const element = this._stack.peekLast();
|
||||
const element = this._stack[this._stack.length - 1];
|
||||
if (!element) {
|
||||
break;
|
||||
}
|
||||
@@ -301,7 +301,7 @@ export class HTMLModel {
|
||||
this._tokens.push(token);
|
||||
this._updateDOM(token);
|
||||
|
||||
const element = this._stack.peekLast();
|
||||
const element = this._stack[this._stack.length - 1];
|
||||
if (element && (element.name === 'script' || element.name === 'style') && element.openTag &&
|
||||
element.openTag.endOffset === lastOffset) {
|
||||
return AbortTokenization;
|
||||
@@ -387,7 +387,7 @@ export class HTMLModel {
|
||||
*/
|
||||
_onTagComplete(tag) {
|
||||
if (tag.isOpenTag) {
|
||||
const topElement = this._stack.peekLast();
|
||||
const topElement = this._stack[this._stack.length - 1];
|
||||
if (topElement) {
|
||||
const tagSet = AutoClosingTags.get(topElement.name);
|
||||
if (topElement !== this._document && topElement.openTag && topElement.openTag.selfClosingTag) {
|
||||
@@ -400,10 +400,10 @@ export class HTMLModel {
|
||||
return;
|
||||
}
|
||||
|
||||
let lastTag = this._stack.peekLast();
|
||||
let lastTag = this._stack[this._stack.length - 1];
|
||||
while (this._stack.length > 1 && lastTag && lastTag.name !== tag.name) {
|
||||
this._popElement(autocloseTag(lastTag, tag.startOffset));
|
||||
lastTag = this._stack.peekLast();
|
||||
lastTag = this._stack[this._stack.length - 1];
|
||||
}
|
||||
if (this._stack.length === 1) {
|
||||
return;
|
||||
@@ -435,7 +435,7 @@ export class HTMLModel {
|
||||
* @param {!Tag} openTag
|
||||
*/
|
||||
_pushElement(openTag) {
|
||||
const topElement = this._stack.peekLast();
|
||||
const topElement = this._stack[this._stack.length - 1];
|
||||
const newElement = new FormatterElement(openTag.name);
|
||||
if (topElement) {
|
||||
newElement.parent = topElement;
|
||||
|
||||
Vendored
-1
@@ -15,7 +15,6 @@ declare class DOM {
|
||||
}
|
||||
|
||||
interface Array<T> {
|
||||
peekLast(): T | undefined;
|
||||
intersectOrdered(array: T[], comparator: (a: T, b: T) => number): T[];
|
||||
mergeOrdered(array: T[], comparator: (a: T, b: T) => number): T[];
|
||||
lowerBound<S>(object: S, comparator?: {(a: S, b: T): number}, left?: number, right?: number): number;
|
||||
|
||||
@@ -269,7 +269,7 @@ export class RemoteObjectPreviewFormatter {
|
||||
* @return {!Element}
|
||||
*/
|
||||
_renderPropertyPreviewOrAccessor(propertyPath) {
|
||||
const property = propertyPath.peekLast();
|
||||
const property = propertyPath[propertyPath.length - 1];
|
||||
if (!property) {
|
||||
throw new Error('Could not find property');
|
||||
}
|
||||
|
||||
@@ -1667,7 +1667,10 @@ export class FlameChart extends UI.Widget.VBox {
|
||||
}
|
||||
|
||||
const groupOffsets = this._groupOffsets;
|
||||
const lastGroupOffset = Array.prototype.peekLast.call(groupOffsets);
|
||||
if (groupOffsets === null || groupOffsets === undefined) {
|
||||
return;
|
||||
}
|
||||
const lastGroupOffset = groupOffsets[groupOffsets.length - 1];
|
||||
const colorUsage = ThemeSupport.ThemeSupport.ColorUsage;
|
||||
|
||||
context.save();
|
||||
@@ -1823,13 +1826,13 @@ export class FlameChart extends UI.Widget.VBox {
|
||||
const groupTop = groupOffsets[i];
|
||||
const group = groups[i];
|
||||
let firstGroup = true;
|
||||
let last = groupStack.peekLast();
|
||||
let last = groupStack[groupStack.length - 1];
|
||||
while (last && last.nestingLevel >= group.style.nestingLevel) {
|
||||
groupStack.pop();
|
||||
firstGroup = false;
|
||||
last = groupStack.peekLast();
|
||||
last = groupStack[groupStack.length - 1];
|
||||
}
|
||||
last = groupStack.peekLast();
|
||||
last = groupStack[groupStack.length - 1];
|
||||
const parentGroupVisible = last ? last.visible : false;
|
||||
const thisGroupVisible = parentGroupVisible && (!this._isGroupCollapsible(i) || group.expanded);
|
||||
groupStack.push({nestingLevel: group.style.nestingLevel, visible: Boolean(thisGroupVisible)});
|
||||
@@ -2138,7 +2141,7 @@ export class FlameChart extends UI.Widget.VBox {
|
||||
/** @type {!Array<{nestingLevel: number, visible: boolean}>} */
|
||||
const groupStack = [{nestingLevel: -1, visible: true}];
|
||||
const lastGroupLevel =
|
||||
Math.max(levelCount, groups.length ? /** @type {!Group} */ (groups.peekLast()).startLevel + 1 : 0);
|
||||
Math.max(levelCount, groups.length ? /** @type {!Group} */ (groups[groups.length - 1]).startLevel + 1 : 0);
|
||||
let level;
|
||||
for (level = 0; level < lastGroupLevel; ++level) {
|
||||
let parentGroupIsVisible = true;
|
||||
@@ -2147,16 +2150,16 @@ export class FlameChart extends UI.Widget.VBox {
|
||||
++groupIndex;
|
||||
style = groups[groupIndex].style;
|
||||
let nextLevel = true;
|
||||
let last = groupStack.peekLast();
|
||||
let last = groupStack[groupStack.length - 1];
|
||||
while (last && last.nestingLevel >= style.nestingLevel) {
|
||||
groupStack.pop();
|
||||
nextLevel = false;
|
||||
last = groupStack.peekLast();
|
||||
last = groupStack[groupStack.length - 1];
|
||||
}
|
||||
const thisGroupIsVisible =
|
||||
groupIndex >= 0 && this._isGroupCollapsible(groupIndex) ? groups[groupIndex].expanded : true;
|
||||
|
||||
last = groupStack.peekLast();
|
||||
last = groupStack[groupStack.length - 1];
|
||||
parentGroupIsVisible = last ? last.visible : false;
|
||||
visible = Boolean(thisGroupIsVisible) && parentGroupIsVisible;
|
||||
groupStack.push({nestingLevel: style.nestingLevel, visible: visible});
|
||||
|
||||
@@ -399,7 +399,8 @@ export class PerformanceMonitorImpl extends UI.Widget.HBox {
|
||||
path.moveTo(x, calcY(0));
|
||||
path.lineTo(this._width + 5, calcY(0));
|
||||
lastY = calcY(
|
||||
/** @type {!{metrics: !Map<string, number>}} */ (this._metricsBuffer.peekLast()).metrics.get(metricName) ||
|
||||
/** @type {!{metrics: !Map<string, number>}} */ (this._metricsBuffer[this._metricsBuffer.length - 1])
|
||||
.metrics.get(metricName) ||
|
||||
0);
|
||||
lastX = this._width + 5;
|
||||
path.lineTo(lastX, lastY);
|
||||
|
||||
@@ -247,7 +247,7 @@ PerformanceTestRunner.forAllEvents = async function(events, callback) {
|
||||
const eventStack = [];
|
||||
|
||||
for (const event of events) {
|
||||
while (eventStack.length && eventStack.peekLast().endTime <= event.startTime) {
|
||||
while (eventStack.length && eventStack[eventStack.length - 1].endTime <= event.startTime) {
|
||||
eventStack.pop();
|
||||
}
|
||||
|
||||
|
||||
@@ -236,18 +236,6 @@ Object.defineProperty(Int32Array.prototype, 'upperBound', {value: Array.prototyp
|
||||
|
||||
Object.defineProperty(Float64Array.prototype, 'lowerBound', {value: Array.prototype.lowerBound, configurable: true});
|
||||
|
||||
Object.defineProperty(Array.prototype, 'peekLast', {
|
||||
/**
|
||||
* @return {!T|undefined}
|
||||
* @this {Array.<!T>}
|
||||
* @template T
|
||||
*/
|
||||
value: function() {
|
||||
return this[this.length - 1];
|
||||
},
|
||||
configurable: true
|
||||
});
|
||||
|
||||
(function() {
|
||||
/**
|
||||
* @param {!Array.<T>} array1
|
||||
|
||||
@@ -551,7 +551,7 @@ export class HeapSnapshotViewportDataGrid extends HeapSnapshotSortableDataGrid {
|
||||
*/
|
||||
revealTreeNode(pathToReveal) {
|
||||
const height = this._calculateOffset(pathToReveal);
|
||||
const node = /** @type {!HeapSnapshotGridNode} */ (pathToReveal.peekLast());
|
||||
const node = /** @type {!HeapSnapshotGridNode} */ (pathToReveal[pathToReveal.length - 1]);
|
||||
const scrollTop = this.scrollContainer.scrollTop;
|
||||
const scrollBottom = scrollTop + this.scrollContainer.offsetHeight;
|
||||
if (height >= scrollTop && height < scrollBottom) {
|
||||
@@ -597,7 +597,7 @@ export class HeapSnapshotViewportDataGrid extends HeapSnapshotSortableDataGrid {
|
||||
}
|
||||
parentNode = node;
|
||||
}
|
||||
return height - /** @type {!HeapSnapshotGridNode} */ (pathToReveal.peekLast()).nodeSelfHeight();
|
||||
return height - /** @type {!HeapSnapshotGridNode} */ (pathToReveal[pathToReveal.length - 1]).nodeSelfHeight();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -311,7 +311,7 @@ export class HeapSnapshotView extends UI.View.SimpleView {
|
||||
profileSamples.ids = samples.lastAssignedIds;
|
||||
profileSamples.timestamps = samples.timestamps;
|
||||
profileSamples.max = samples.sizes;
|
||||
profileSamples.totalTime = Math.max(samples.timestamps.peekLast() || 0, 10000);
|
||||
profileSamples.totalTime = Math.max(samples.timestamps[samples.timestamps.length - 1] || 0, 10000);
|
||||
if (this._trackingOverviewGrid) {
|
||||
this._trackingOverviewGrid.setSamples(profileSamples);
|
||||
}
|
||||
|
||||
@@ -459,14 +459,14 @@ export class FilteredListWidget extends UI.Widget.VBox {
|
||||
bestItems.splice(index, 0, i);
|
||||
if (bestScores.length > bestItemsToCollect) {
|
||||
// Best list is too large -> drop last elements.
|
||||
const bestItemLast = bestItems.peekLast();
|
||||
const bestItemLast = bestItems[bestItems.length - 1];
|
||||
if (bestItemLast) {
|
||||
overflowItems.push(bestItemLast);
|
||||
}
|
||||
bestScores.length = bestItemsToCollect;
|
||||
bestItems.length = bestItemsToCollect;
|
||||
}
|
||||
const bestScoreLast = bestScores.peekLast();
|
||||
const bestScoreLast = bestScores[bestScores.length - 1];
|
||||
if (bestScoreLast) {
|
||||
minBestScore = bestScoreLast;
|
||||
}
|
||||
|
||||
@@ -287,11 +287,11 @@ export class CPUProfileDataModel extends ProfileTreeModel {
|
||||
if (this.samples.length === timestamps.length) {
|
||||
// Support for a legacy format where were no timeDeltas.
|
||||
// Add an extra timestamp used to calculate the last sample duration.
|
||||
const averageSample = ((timestamps.peekLast() || 0) - timestamps[0]) / (timestamps.length - 1);
|
||||
this.timestamps.push((timestamps.peekLast() || 0) + averageSample);
|
||||
const averageSample = ((timestamps[timestamps.length - 1] || 0) - timestamps[0]) / (timestamps.length - 1);
|
||||
this.timestamps.push((timestamps[timestamps.length - 1] || 0) + averageSample);
|
||||
}
|
||||
this.profileStartTime = timestamps[0];
|
||||
this.profileEndTime = /** @type {number} */ (timestamps.peekLast());
|
||||
this.profileEndTime = /** @type {number} */ (timestamps[timestamps.length - 1]);
|
||||
}
|
||||
|
||||
_buildIdToNodeMap() {
|
||||
|
||||
@@ -77,7 +77,7 @@ export class CSSMatchedStyles {
|
||||
// Merge UA rules that are sequential and have similar selector/media.
|
||||
const cleanMatchedPayload = [];
|
||||
for (const ruleMatch of payload) {
|
||||
const lastMatch = cleanMatchedPayload.peekLast();
|
||||
const lastMatch = cleanMatchedPayload[cleanMatchedPayload.length - 1];
|
||||
if (!lastMatch || ruleMatch.rule.origin !== 'user-agent' || lastMatch.rule.origin !== 'user-agent' ||
|
||||
ruleMatch.rule.selectorList.text !== lastMatch.rule.selectorList.text ||
|
||||
mediaText(ruleMatch) !== mediaText(lastMatch)) {
|
||||
|
||||
@@ -1739,7 +1739,7 @@ class RedirectExtraInfoBuilder {
|
||||
|
||||
if (this._hasExtraInfo) {
|
||||
// if we haven't gotten the last responseExtraInfo event, we have to wait for it.
|
||||
const lastItem = this._requests.peekLast();
|
||||
const lastItem = this._requests[this._requests.length - 1];
|
||||
if (lastItem && !lastItem.hasExtraResponseInfo()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -529,7 +529,8 @@ export class RuntimeModel extends SDKModel {
|
||||
* @return {!Promise<boolean>}
|
||||
*/
|
||||
async checkSideEffectSupport() {
|
||||
const testContext = this.executionContexts().peekLast();
|
||||
const contexts = this.executionContexts();
|
||||
const testContext = contexts[contexts.length - 1];
|
||||
if (!testContext) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -443,7 +443,7 @@ export class TracingModel {
|
||||
|
||||
case phase.NestableAsyncInstant: {
|
||||
if (openEventsStack && openEventsStack.length) {
|
||||
const event = openEventsStack.peekLast();
|
||||
const event = openEventsStack[openEventsStack.length - 1];
|
||||
if (event) {
|
||||
event._addStep(event);
|
||||
}
|
||||
@@ -497,7 +497,7 @@ export class TracingModel {
|
||||
return;
|
||||
}
|
||||
if (event.phase === phase.AsyncStepInto || event.phase === phase.AsyncStepPast) {
|
||||
const lastStep = asyncEvent.steps.peekLast();
|
||||
const lastStep = asyncEvent.steps[asyncEvent.steps.length - 1];
|
||||
if (lastStep && lastStep.phase !== phase.AsyncBegin && lastStep.phase !== event.phase) {
|
||||
console.assert(
|
||||
false, 'Async event step phase mismatch: ' + lastStep.phase + ' at ' + lastStep.startTime + ' vs. ' +
|
||||
|
||||
@@ -304,7 +304,7 @@ export class Counter {
|
||||
* @param {number} value
|
||||
*/
|
||||
appendSample(time, value) {
|
||||
if (this.values.length && this.values.peekLast() === value) {
|
||||
if (this.values.length && this.values[this.values.length - 1] === value) {
|
||||
return;
|
||||
}
|
||||
this.times.push(time);
|
||||
|
||||
@@ -86,7 +86,7 @@ export class EventsTimelineTreeView extends TimelineTreeView {
|
||||
|
||||
while (iterators.length) {
|
||||
// @ts-ignore crbug.com/1011811 there is no common iterator type between Closure and TypeScript
|
||||
const iterator = iterators.peekLast().next();
|
||||
const iterator = iterators[iterators.length - 1].next();
|
||||
if (iterator.done) {
|
||||
iterators.pop();
|
||||
continue;
|
||||
|
||||
@@ -356,8 +356,8 @@ export class TimelineController {
|
||||
}
|
||||
} else {
|
||||
// Legacy backends support.
|
||||
const mainMetaEvent =
|
||||
metadataEvents.filter(event => event.name === metadataEventTypes.TracingStartedInPage).peekLast();
|
||||
const filteredEvents = metadataEvents.filter(event => event.name === metadataEventTypes.TracingStartedInPage);
|
||||
const mainMetaEvent = filteredEvents[filteredEvents.length - 1];
|
||||
if (mainMetaEvent) {
|
||||
const pid = mainMetaEvent.thread.process().id();
|
||||
if (this._tracingManager) {
|
||||
|
||||
@@ -269,7 +269,7 @@ export class TimelineEventOverviewCPUActivity extends TimelineEventOverview {
|
||||
* @param {!SDK.TracingModel.Event} e
|
||||
*/
|
||||
function onEventStart(e) {
|
||||
const index = categoryIndexStack.length ? categoryIndexStack.peekLast() : idleIndex;
|
||||
const index = categoryIndexStack.length ? categoryIndexStack[categoryIndexStack.length - 1] : idleIndex;
|
||||
quantizer.appendInterval(e.startTime, /** @type {number} */ (index));
|
||||
categoryIndexStack.push(categoryToIndex.get(TimelineUIUtils.eventStyle(e).category) || otherIndex);
|
||||
}
|
||||
@@ -565,7 +565,7 @@ export class TimelineEventOverviewFrames extends TimelineEventOverview {
|
||||
ctx.lineTo(x, y + tickDepth);
|
||||
ctx.lineTo(x, y);
|
||||
}
|
||||
const lastFrame = frames.peekLast();
|
||||
const lastFrame = frames[frames.length - 1];
|
||||
if (lastFrame) {
|
||||
x = Math.round((lastFrame.startTime + lastFrame.duration - timeOffset) * scale) + offset;
|
||||
}
|
||||
|
||||
@@ -573,14 +573,15 @@ export class TimelineFlameChartDataProvider extends Common.ObjectWrapper.ObjectW
|
||||
continue;
|
||||
}
|
||||
}
|
||||
while (openEvents.length &&
|
||||
/** @type {number} */ (/** @type {!SDK.TracingModel.Event} */ (openEvents.peekLast()).endTime) <=
|
||||
e.startTime) {
|
||||
while (
|
||||
openEvents.length &&
|
||||
/** @type {number} */ (/** @type {!SDK.TracingModel.Event} */ (openEvents[openEvents.length - 1]).endTime) <=
|
||||
e.startTime) {
|
||||
openEvents.pop();
|
||||
}
|
||||
eventToDisallowRoot.set(e, false);
|
||||
if (ignoreListingEnabled && this._isIgnoreListedEvent(e)) {
|
||||
const parent = openEvents.peekLast();
|
||||
const parent = openEvents[openEvents.length - 1];
|
||||
if (parent && eventToDisallowRoot.get(parent)) {
|
||||
continue;
|
||||
}
|
||||
@@ -596,7 +597,7 @@ export class TimelineFlameChartDataProvider extends Common.ObjectWrapper.ObjectW
|
||||
const level = this._currentLevel + openEvents.length;
|
||||
const index = this._appendEvent(e, level);
|
||||
if (openEvents.length) {
|
||||
this._entryParent[index] = /** @type {!SDK.TracingModel.Event} */ (openEvents.peekLast());
|
||||
this._entryParent[index] = /** @type {!SDK.TracingModel.Event} */ (openEvents[openEvents.length - 1]);
|
||||
}
|
||||
if (!isExtension && this._performanceModel.timelineModel().isMarkerEvent(e)) {
|
||||
// @ts-ignore This is invalid code, but we should keep it for now
|
||||
@@ -832,7 +833,7 @@ export class TimelineFlameChartDataProvider extends Common.ObjectWrapper.ObjectW
|
||||
const hasFilmStrip = Boolean(screenshots.length);
|
||||
this._framesHeader.collapsible = hasFilmStrip;
|
||||
this._appendHeader(Common.UIString.UIString('Frames'), this._framesHeader, false /* selectable */);
|
||||
this._frameGroup = this._timelineData.groups.peekLast();
|
||||
this._frameGroup = this._timelineData.groups[this._timelineData.groups.length - 1];
|
||||
const style = TimelineUIUtils.markerStyleForFrame();
|
||||
|
||||
this._entryTypeByLevel[this._currentLevel] = EntryType.Frame;
|
||||
|
||||
@@ -254,7 +254,8 @@ export class TimelineHistoryManager {
|
||||
container.style.width = this._totalHeight * thumbnailAspectRatio + 'px';
|
||||
container.style.height = this._totalHeight + 'px';
|
||||
const filmStripModel = performanceModel.filmStripModel();
|
||||
const lastFrame = filmStripModel.frames().peekLast();
|
||||
const frames = filmStripModel.frames();
|
||||
const lastFrame = frames[frames.length - 1];
|
||||
if (!lastFrame) {
|
||||
return container;
|
||||
}
|
||||
|
||||
@@ -1334,7 +1334,7 @@ export class TimelineUIUtils {
|
||||
if (index === 0) {
|
||||
value = 0;
|
||||
} else if (index === categoryCache.time.length) {
|
||||
value = categoryCache.value.peekLast();
|
||||
value = categoryCache.value[categoryCache.value.length - 1];
|
||||
} else {
|
||||
const t0 = categoryCache.time[index - 1];
|
||||
const t1 = categoryCache.time[index];
|
||||
@@ -1397,7 +1397,7 @@ export class TimelineUIUtils {
|
||||
statsArrays = {time: [], value: []};
|
||||
aggregatedStats[category] = statsArrays;
|
||||
}
|
||||
if (statsArrays.time.length && statsArrays.time.peekLast() === time || lastTime > time) {
|
||||
if (statsArrays.time.length && statsArrays.time[statsArrays.time.length - 1] === time || lastTime > time) {
|
||||
return;
|
||||
}
|
||||
const lastValue = statsArrays.value.length > 0 ? statsArrays.value[statsArrays.value.length - 1] : 0;
|
||||
@@ -1425,7 +1425,7 @@ export class TimelineUIUtils {
|
||||
*/
|
||||
function onStartEvent(e) {
|
||||
const category = TimelineUIUtils.eventStyle(e).category.name;
|
||||
const parentCategory = categoryStack.length ? categoryStack.peekLast() : null;
|
||||
const parentCategory = categoryStack.length ? categoryStack[categoryStack.length - 1] : null;
|
||||
if (category !== parentCategory) {
|
||||
categoryChange(parentCategory || null, category, e.startTime);
|
||||
}
|
||||
@@ -1437,7 +1437,7 @@ export class TimelineUIUtils {
|
||||
*/
|
||||
function onEndEvent(e) {
|
||||
const category = categoryStack.pop();
|
||||
const parentCategory = categoryStack.length ? categoryStack.peekLast() : null;
|
||||
const parentCategory = categoryStack.length ? categoryStack[categoryStack.length - 1] : null;
|
||||
if (category !== parentCategory) {
|
||||
categoryChange(category || null, parentCategory || null, e.endTime || 0);
|
||||
}
|
||||
|
||||
@@ -252,7 +252,7 @@ export class TimelineFrameModel {
|
||||
if (this._lastLayerTree) {
|
||||
this._lastLayerTree._setPaints(frame._paints);
|
||||
}
|
||||
const lastFrame = this._frames.peekLast();
|
||||
const lastFrame = this._frames[this._frames.length - 1];
|
||||
if (this._frames.length && lastFrame &&
|
||||
(frame.startTime !== lastFrame.endTime || frame.startTime > frame.endTime)) {
|
||||
console.assert(
|
||||
|
||||
@@ -141,7 +141,7 @@ export class TimelineJSProfileProcessor {
|
||||
*/
|
||||
function truncateJSStack(depth, time) {
|
||||
if (lockedJsStackDepth.length) {
|
||||
const lockedDepth = /** @type {number}*/ (lockedJsStackDepth.peekLast());
|
||||
const lockedDepth = /** @type {number}*/ (lockedJsStackDepth[lockedJsStackDepth.length - 1]);
|
||||
if (depth < lockedDepth) {
|
||||
console.error(`Child stack is shallower (${depth}) than the parent stack (${lockedDepth}) at ${time}`);
|
||||
depth = lockedDepth;
|
||||
@@ -208,7 +208,7 @@ export class TimelineJSProfileProcessor {
|
||||
const endTime = e.endTime || e.startTime;
|
||||
const minFrames = Math.min(callFrames.length, jsFramesStack.length);
|
||||
let i;
|
||||
for (i = lockedJsStackDepth.peekLast() || 0; i < minFrames; ++i) {
|
||||
for (i = lockedJsStackDepth[lockedJsStackDepth.length - 1] || 0; i < minFrames; ++i) {
|
||||
const newFrame = callFrames[i];
|
||||
const oldFrame = jsFramesStack[i].args['data'];
|
||||
if (!equalFrames(newFrame, oldFrame)) {
|
||||
|
||||
@@ -130,11 +130,11 @@ export class TimelineModelImpl {
|
||||
if (SDK.TracingModel.TracingModel.isAsyncPhase(e.phase) || SDK.TracingModel.TracingModel.isFlowPhase(e.phase)) {
|
||||
continue;
|
||||
}
|
||||
let last = stack.peekLast();
|
||||
let last = stack[stack.length - 1];
|
||||
while (last && last.endTime !== undefined && last.endTime <= e.startTime) {
|
||||
stack.pop();
|
||||
onEndEvent(last);
|
||||
last = stack.peekLast();
|
||||
last = stack[stack.length - 1];
|
||||
}
|
||||
if (filter && !filter(e)) {
|
||||
continue;
|
||||
@@ -143,7 +143,7 @@ export class TimelineModelImpl {
|
||||
onStartEvent(e);
|
||||
stack.push(e);
|
||||
} else {
|
||||
onInstantEvent && onInstantEvent(e, stack.peekLast() || null);
|
||||
onInstantEvent && onInstantEvent(e, stack[stack.length - 1] || null);
|
||||
}
|
||||
}
|
||||
while (stack.length) {
|
||||
@@ -470,7 +470,7 @@ export class TimelineModelImpl {
|
||||
let lastMainUrl = null;
|
||||
let hasMain = false;
|
||||
for (const item of data) {
|
||||
const last = ranges.peekLast();
|
||||
const last = ranges[ranges.length - 1];
|
||||
if (!last || item.from > last.to) {
|
||||
ranges.push({from: item.from, to: item.to});
|
||||
} else {
|
||||
@@ -676,7 +676,8 @@ export class TimelineModelImpl {
|
||||
let target = null;
|
||||
|
||||
// Check for legacy CpuProfile event format first.
|
||||
let cpuProfileEvent = events.peekLast();
|
||||
/** @type {(SDK.TracingModel.Event|undefined)} */
|
||||
let cpuProfileEvent = events[events.length - 1];
|
||||
if (cpuProfileEvent && cpuProfileEvent.name === RecordType.CpuProfile) {
|
||||
const eventData = cpuProfileEvent.args['data'];
|
||||
cpuProfile = /** @type {?Protocol.Profiler.Profile} */ (eventData && eventData['cpuProfile']);
|
||||
@@ -856,17 +857,17 @@ export class TimelineModelImpl {
|
||||
this._estimatedTotalBlockingTime += event.duration - 50;
|
||||
}
|
||||
|
||||
let last = eventStack.peekLast();
|
||||
let last = eventStack[eventStack.length - 1];
|
||||
while (last && last.endTime !== undefined && last.endTime <= event.startTime) {
|
||||
eventStack.pop();
|
||||
last = eventStack.peekLast();
|
||||
last = eventStack[eventStack.length - 1];
|
||||
}
|
||||
if (!this._processEvent(event)) {
|
||||
continue;
|
||||
}
|
||||
if (!SDK.TracingModel.TracingModel.isAsyncPhase(event.phase) && event.duration) {
|
||||
if (eventStack.length) {
|
||||
const parent = eventStack.peekLast();
|
||||
const parent = eventStack[eventStack.length - 1];
|
||||
if (parent) {
|
||||
parent.selfTime -= event.duration;
|
||||
if (parent.selfTime < 0) {
|
||||
@@ -952,7 +953,7 @@ export class TimelineModelImpl {
|
||||
|
||||
if (asyncEvent.hasCategory(TimelineModelImpl.Category.LatencyInfo) ||
|
||||
asyncEvent.name === RecordType.ImplSideFling) {
|
||||
const lastStep = asyncEvent.steps.peekLast();
|
||||
const lastStep = asyncEvent.steps[asyncEvent.steps.length - 1];
|
||||
if (!lastStep) {
|
||||
throw new Error('AsyncEvent.steps access is out of bounds.');
|
||||
}
|
||||
@@ -1037,7 +1038,7 @@ export class TimelineModelImpl {
|
||||
}
|
||||
}
|
||||
let pageFrameId = TimelineModelImpl.eventFrameId(event);
|
||||
const last = eventStack.peekLast();
|
||||
const last = eventStack[eventStack.length - 1];
|
||||
if (!pageFrameId && last) {
|
||||
pageFrameId = TimelineData.forEvent(last).frameId;
|
||||
}
|
||||
@@ -1051,7 +1052,7 @@ export class TimelineModelImpl {
|
||||
switch (event.name) {
|
||||
case recordTypes.ResourceSendRequest:
|
||||
case recordTypes.WebSocketCreate: {
|
||||
timelineData.setInitiator(eventStack.peekLast() || null);
|
||||
timelineData.setInitiator(eventStack[eventStack.length - 1] || null);
|
||||
timelineData.url = eventData['url'];
|
||||
break;
|
||||
}
|
||||
@@ -1834,7 +1835,7 @@ export class Track {
|
||||
* @return {number}
|
||||
*/
|
||||
function peekLastEndTime() {
|
||||
const last = stack.peekLast();
|
||||
const last = stack[stack.length - 1];
|
||||
if (last !== undefined) {
|
||||
const endTime = last.endTime;
|
||||
if (endTime !== undefined) {
|
||||
|
||||
@@ -375,7 +375,7 @@ export class SubMenu extends Item {
|
||||
}
|
||||
result.subItems.push(item._buildDescriptor());
|
||||
}
|
||||
if (section !== nonEmptySections.peekLast()) {
|
||||
if (section !== nonEmptySections[nonEmptySections.length - 1]) {
|
||||
if (!result.subItems) {
|
||||
result.subItems = [];
|
||||
}
|
||||
|
||||
@@ -396,7 +396,7 @@ export class Toolbar {
|
||||
nonSeparatorVisible = true;
|
||||
}
|
||||
}
|
||||
if (lastSeparator && lastSeparator !== this._items.peekLast()) {
|
||||
if (lastSeparator && lastSeparator !== this._items[this._items.length - 1]) {
|
||||
lastSeparator.setVisible(false);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user