author | Nicholas Nethercote <nnethercote@mozilla.com> |
Fri, 19 Oct 2018 15:09:46 +1100 | |
changeset 497861 | 51a3a633315cebea2c31fb871d6c35300b529313 |
parent 497860 | d091653eec100d84b4c1e7fd78e05aa9257a5f08 |
child 497862 | 838f16e6dcf2239d5b94dc5d5086f22558467dba |
push id | 10002 |
push user | archaeopteryx@coole-files.de |
push date | Fri, 19 Oct 2018 23:09:29 +0000 |
treeherder | mozilla-beta@01378c910610 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | erahm |
bugs | 1499906 |
milestone | 64.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
toolkit/components/aboutmemory/content/aboutMemory.js | file | annotate | diff | comparison | revisions |
--- a/toolkit/components/aboutmemory/content/aboutMemory.js +++ b/toolkit/components/aboutmemory/content/aboutMemory.js @@ -397,19 +397,19 @@ function onLoad() { appendElementWithText(gFooter, "div", "legend hiddenOnMobile", legendText2); // See if we're loading from a file. (Because about:memory is a non-standard // URL, location.search is undefined, so we have to use location.href // instead.) let search = location.href.split("?")[1]; if (search) { let searchSplit = search.split("&"); - for (let i = 0; i < searchSplit.length; i++) { - if (searchSplit[i].toLowerCase().startsWith("file=")) { - let filename = searchSplit[i].substring("file=".length); + for (let s of searchSplit) { + if (s.toLowerCase().startsWith("file=")) { + let filename = s.substring("file=".length); updateAboutMemoryFromFile(decodeURIComponent(filename)); return; } } } } // --------------------------------------------------------------------------- @@ -561,18 +561,17 @@ function updateAboutMemoryFromJSONObject "data version number missing or doesn't match"); assertInput(aObj.hasMozMallocUsableSize !== undefined, "missing 'hasMozMallocUsableSize' property"); assertInput(aObj.reports && aObj.reports instanceof Array, "missing or non-array 'reports' property"); let processMemoryReportsFromFile = function(aHandleReport, aDisplayReports) { - for (let i = 0; i < aObj.reports.length; i++) { - let r = aObj.reports[i]; + for (let r of aObj.reports) { aHandleReport(r.process, r.path, r.kind, r.units, r.amount, r.description, r._presence); } aDisplayReports(); }; appendAboutMemoryMain(processMemoryReportsFromFile, aObj.hasMozMallocUsableSize); } catch (ex) { @@ -767,19 +766,17 @@ DReport.ADDED_FOR_BALANCE = 3; * DReport objects for values. * * @param aJSONReports * The |reports| field of a JSON object. * @return The constructed report map. */ function makeDReportMap(aJSONReports) { let dreportMap = {}; - for (let i = 0; i < aJSONReports.length; i++) { - let jr = aJSONReports[i]; - + for (let jr of aJSONReports) { assert(jr.process !== undefined, "Missing process"); assert(jr.path !== undefined, "Missing path"); assert(jr.kind !== undefined, "Missing kind"); assert(jr.units !== undefined, "Missing units"); assert(jr.amount !== undefined, "Missing amount"); assert(jr.description !== undefined, "Missing description"); // Strip out some non-deterministic stuff that prevents clean diffs. @@ -1040,18 +1037,17 @@ function appendAboutMemoryMain(aProcessR if (aProcessA > aProcessB) { return 1; } return 0; }); // Generate output for each process. - for (let i = 0; i < processes.length; i++) { - let process = processes[i]; + for (let [i, process] of processes.entries()) { let section = appendElement(gMain, "div", "section"); appendProcessAboutMemoryElements(section, i, process, pcollsByProcess[process]._trees, pcollsByProcess[process]._degenerates, pcollsByProcess[process]._heapTotal, aHasMozMallocUsableSize); } @@ -1087,19 +1083,19 @@ function TreeNode(aUnsafeName, aUnits, a // - _description // - _hideKids (only defined if true) // - _maxAbsDescendant (on-demand, only when gIsDiff is set) } TreeNode.prototype = { findKid(aUnsafeName) { if (this._kids) { - for (let i = 0; i < this._kids.length; i++) { - if (this._kids[i]._unsafeName === aUnsafeName) { - return this._kids[i]; + for (let kid of this._kids) { + if (kid._unsafeName === aUnsafeName) { + return kid; } } } return undefined; }, // When gIsDiff is false, tree operations -- sorting and determining if a // sub-tree is significant -- are straightforward. But when gIsDiff is true, @@ -1115,18 +1111,18 @@ TreeNode.prototype = { if ("_maxAbsDescendant" in this) { // We've computed this before? Return the saved value. return this._maxAbsDescendant; } // Compute the maximum absolute value of all descendants. let max = Math.abs(this._amount); - for (let i = 0; i < this._kids.length; i++) { - max = Math.max(max, this._kids[i].maxAbsDescendant()); + for (let kid of this._kids) { + max = Math.max(max, kid.maxAbsDescendant()); } this._maxAbsDescendant = max; return max; }, toString() { switch (this._units) { case UNITS_BYTES: return formatBytes(this._amount); @@ -1195,18 +1191,18 @@ function fillInTree(aRoot) { aT._nMerged = kid._nMerged; } assert(!aT._hideKids && !kid._hideKids, "_hideKids set when merging"); } else { // Non-leaf node with multiple children. Derive its _amount and // _description entirely from its children... let kidsBytes = 0; - for (let i = 0; i < aT._kids.length; i++) { - kidsBytes += fillInNonLeafNodes(aT._kids[i]); + for (let kid of aT._kids) { + kidsBytes += fillInNonLeafNodes(kid); } // ... except in one special case. When diffing two memory report sets, // if one set has a node with children and the other has the same node // but without children -- e.g. the first has "a/b/c" and "a/b/d", but // the second only has "a/b" -- we need to add a fake node "a/b/(fake)" // to the second to make the trees comparable. It's ugly, but it works. if (aT._amount !== undefined && @@ -1295,18 +1291,18 @@ function sortTreeAndInsertAggregateNodes aT._kids.sort(TreeNode.compareAmounts); // If the first child is insignificant, they all are, and there's no point // creating an aggregate node that lacks siblings. Just set the parent's // _hideKids property and process all children. if (isInsignificant(aT._kids[0])) { aT._hideKids = true; - for (let i = 0; i < aT._kids.length; i++) { - sortTreeAndInsertAggregateNodes(aTotalBytes, aT._kids[i]); + for (let kid of aT._kids) { + sortTreeAndInsertAggregateNodes(aTotalBytes, kid); } return; } // Look at all children except the last one. let i; for (i = 0; i < aT._kids.length - 1; i++) { if (isInsignificant(aT._kids[i])) { @@ -1327,18 +1323,18 @@ function sortTreeAndInsertAggregateNodes aggT._amount = aggBytes; aggT._description = nAgg + " sub-trees that are below the " + kSignificanceThresholdPerc + "% significance threshold."; aT._kids.splice(i0, nAgg, aggT); aT._kids.sort(TreeNode.compareAmounts); // Process the moved children. - for (i = 0; i < aggT._kids.length; i++) { - sortTreeAndInsertAggregateNodes(aTotalBytes, aggT._kids[i]); + for (let kid of aggT._kids) { + sortTreeAndInsertAggregateNodes(aTotalBytes, kid); } return; } sortTreeAndInsertAggregateNodes(aTotalBytes, aT._kids[i]); } // The first n-1 children were significant. Don't consider if the last child @@ -1482,23 +1478,21 @@ function appendProcessAboutMemoryElement maxStringLength = length; } otherDegenerates.push(t); } otherDegenerates.sort(TreeNode.compareUnsafeNames); // Now generate the elements, putting non-degenerate trees first. let pre = appendSectionHeader(aP, "Other Measurements"); - for (let i = 0; i < otherTrees.length; i++) { - let t = otherTrees[i]; + for (let t of otherTrees) { appendTreeElements(pre, t, aProcess, ""); appendTextNode(pre, "\n"); // blank lines after non-degenerate trees } - for (let i = 0; i < otherDegenerates.length; i++) { - let t = otherDegenerates[i]; + for (let t of otherDegenerates) { let padText = pad("", maxStringLength - t.toString().length, " "); appendTreeElements(pre, t, aProcess, padText); } appendTextNode(aP, "\n"); // gives nice spacing when we copy and paste // Add any warnings about inaccuracies in the "explicit" tree due to platform // limitations. These must be computed after generating all the text. The // newlines give nice spacing if we copy+paste into a text buffer. @@ -1887,18 +1881,17 @@ function appendTreeElements(aP, aRoot, a let tlThisForMost, tlKidsForMost; if (aT._kids.length > 1) { tlThisForMost = aTlKids + "├──"; tlKidsForMost = aTlKids + "│ "; } let tlThisForLast = aTlKids + "└──"; let tlKidsForLast = aTlKids + " "; - for (let i = 0; i < aT._kids.length; i++) { - let kid = aT._kids[i]; + for (let [i, kid] of aT._kids.entries()) { let isLast = i == aT._kids.length - 1; aUnsafeNames.push(kid._unsafeName); appendTreeElements2(d, aProcess, aUnsafeNames, aRoot, kid, !isLast ? tlThisForMost : tlThisForLast, !isLast ? tlKidsForMost : tlKidsForLast, valueText.length); aUnsafeNames.pop(); }