Use String.prototype.repeat()
in a couple of spots
Rather than using a temporary Array to manually create repeated strings, we can use `String.prototype.repeat()` instead. The reason that we didn't use this from the start is most likely because some browsers, notably IE, didn't support this; note https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat#browser_compatibility
This commit is contained in:
parent
d6592b5e37
commit
addb4cb12b
@ -717,11 +717,7 @@ class Catalog {
|
|||||||
const character = String.fromCharCode(
|
const character = String.fromCharCode(
|
||||||
baseCharCode + (letterIndex % LIMIT)
|
baseCharCode + (letterIndex % LIMIT)
|
||||||
);
|
);
|
||||||
const charBuf = [];
|
currentLabel = character.repeat(Math.floor(letterIndex / LIMIT) + 1);
|
||||||
for (let j = 0, jj = (letterIndex / LIMIT) | 0; j <= jj; j++) {
|
|
||||||
charBuf.push(character);
|
|
||||||
}
|
|
||||||
currentLabel = charBuf.join("");
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (style) {
|
if (style) {
|
||||||
|
@ -261,10 +261,9 @@ describe("evaluator", function () {
|
|||||||
"(bug 1443140)",
|
"(bug 1443140)",
|
||||||
async function () {
|
async function () {
|
||||||
const NUM_INVALID_OPS = 25;
|
const NUM_INVALID_OPS = 25;
|
||||||
const tempArr = new Array(NUM_INVALID_OPS + 1);
|
|
||||||
|
|
||||||
// Non-path operators, should be ignored.
|
// Non-path operators, should be ignored.
|
||||||
const invalidMoveText = tempArr.join("10 Td\n");
|
const invalidMoveText = "10 Td\n".repeat(NUM_INVALID_OPS);
|
||||||
const moveTextStream = new StringStream(invalidMoveText);
|
const moveTextStream = new StringStream(invalidMoveText);
|
||||||
const result = await runOperatorListCheck(
|
const result = await runOperatorListCheck(
|
||||||
partialEvaluator,
|
partialEvaluator,
|
||||||
@ -275,7 +274,7 @@ describe("evaluator", function () {
|
|||||||
expect(result.fnArray).toEqual([]);
|
expect(result.fnArray).toEqual([]);
|
||||||
|
|
||||||
// Path operators, should throw error.
|
// Path operators, should throw error.
|
||||||
const invalidLineTo = tempArr.join("20 l\n");
|
const invalidLineTo = "20 l\n".repeat(NUM_INVALID_OPS);
|
||||||
const lineToStream = new StringStream(invalidLineTo);
|
const lineToStream = new StringStream(invalidLineTo);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -49,9 +49,8 @@ describe("util", function () {
|
|||||||
bytes[i] = "a".charCodeAt(0);
|
bytes[i] = "a".charCodeAt(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a string with `length` 'a' characters. We need an array of size
|
// Create a string with `length` 'a' characters.
|
||||||
// `length + 1` since `join` puts the argument between the array elements.
|
const string = "a".repeat(length);
|
||||||
const string = Array(length + 1).join("a");
|
|
||||||
|
|
||||||
expect(bytesToString(bytes)).toEqual(string);
|
expect(bytesToString(bytes)).toEqual(string);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user