Bug 1499906 - Use String.prototype.padStart(). r=erahm
☠☠ backed out by be3ea7eb7ff4 ☠ ☠
authorNicholas Nethercote <nnethercote@mozilla.com>
Fri, 19 Oct 2018 11:27:30 +1100
changeset 500565 eeea7ba794c30def2083f1a7555228b84d7b4626
parent 500564 9819dbed2d88c0aa7f4832a0cee383e68481ebd8
child 500566 a4e7eb7be03c2d1b51fd3b3ee355720d999fb2a9
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerserahm
bugs1499906
milestone64.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
Bug 1499906 - Use String.prototype.padStart(). r=erahm This lets us remove pad().
toolkit/components/aboutmemory/content/aboutMemory.js
--- 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) {