Bug 1499906 (attempt 2) - Use String.prototype.padStart(). r=erahm
--- a/toolkit/components/aboutmemory/content/aboutMemory.js
+++ b/toolkit/components/aboutmemory/content/aboutMemory.js
@@ -1483,17 +1483,17 @@ function appendProcessAboutMemoryElement
// Now generate the elements, putting non-degenerate trees first.
let pre = appendSectionHeader(aP, "Other Measurements");
for (let t of otherTrees) {
appendTreeElements(pre, t, aProcess, "");
appendTextNode(pre, "\n"); // blank lines after non-degenerate trees
}
for (let t of otherDegenerates) {
- let padText = pad("", maxStringLength - t.toString().length, " ");
+ let padText = "".padStart(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.
if (hasExplicitTree) {
@@ -1589,36 +1589,16 @@ function formatTreeFrac(aNum, aDenom) {
// alignment. For positive numbers, 00.00%--99.99% works straighforwardly,
// but 100.0% needs special handling.
let num = aDenom === 0 ? 1 : (aNum / aDenom);
return (0.99995 <= num && num <= 1)
? formatNum(1, kFrac1Style)
: formatNum(num, kFracStyle);
}
-/**
- * Right-justifies a string in a field of a given width, padding as necessary.
- *
- * @param aS
- * The string.
- * @param aN
- * The field width.
- * @param aC
- * The char used to pad.
- * @return The string representation.
- */
-function pad(aS, aN, aC) {
- let padding = "";
- let n2 = aN - aS.length;
- for (let i = 0; i < n2; i++) {
- padding += aC;
- }
- return padding + aS;
-}
-
const kNoKidsSep = " ── ",
kHideKidsSep = " ++ ",
kShowKidsSep = " -- ";
function appendMrNameSpan(aP, aDescription, aUnsafeName, aIsInvalid, aNMerged,
aPresence) {
let safeName = flipBackslashes(aUnsafeName);
if (!aIsInvalid && !aNMerged && !aPresence) {