Repository: mozilla/pdf.js
File: src/core/operator_list.js (JavaScript)

Code before:
      iFirstBeginText >= 4 &&
      fnArray[iFirstBeginText - 4] === fnArray[iFirstSetFont] &&
      fnArray[iFirstBeginText - 3] === fnArray[iFirstSetTextMatrix] &&
      fnArray[iFirstBeginText - 2] === fnArray[iFirstShowText] &&
      fnArray[iFirstBeginText - 1] === fnArray[iFirstEndText] &&
      argsArray[iFirstBeginText - 4][0] === firstSetFontArg0 &&
      argsArray[iFirstBeginText - 4][1] === firstSetFontArg1
    ) {
      count++;
      iFirst -= 5;
    }

    // Remove (endText, beginText, setFont) trios.
    let iEndText = iFirst + 4;
    for (let q = 1; q < count; q++) {
      fnArray.splice(iEndText, 3);
      argsArray.splice(iEndText, 3);
      iEndText += 2;
    }

    return iEndText + 1;
  }
);

// This replaces (save, transform, constructPath, restore)
// sequences |constructPath| operation.
addState(
  InitialState,
  [OPS.save, OPS.transform, OPS.constructPath, OPS.restore],
  context => {
    const argsArray = context.argsArray;
    const iFirstConstructPath = context.iCurr - 1;
    const op = argsArray[iFirstConstructPath][0];

    // When stroking the transform has to be applied to the line width too.
    // So we can only optimize if the transform is an identity.
    if (
      op !== OPS.stroke &&
      op !== OPS.closeStroke &&
      op !== OPS.fillStroke &&
      op !== OPS.eoFillStroke &&
      op !== OPS.closeFillStroke &&
      op !== OPS.closeEOFillStroke
    ) {
      return true;
    }
    const iFirstTransform = context.iCurr - 2;
    const transform = argsArray[iFirstTransform];
    return (
      transform[0] === 1 &&
      transform[1] === 0 &&

Review comment (suggestion):
```suggestion
// This replaces (save, transform, constructPath, restore)
// sequences with |constructPath| operation.
```

Code after:
      iFirstBeginText >= 4 &&
      fnArray[iFirstBeginText - 4] === fnArray[iFirstSetFont] &&
      fnArray[iFirstBeginText - 3] === fnArray[iFirstSetTextMatrix] &&
      fnArray[iFirstBeginText - 2] === fnArray[iFirstShowText] &&
      fnArray[iFirstBeginText - 1] === fnArray[iFirstEndText] &&
      argsArray[iFirstBeginText - 4][0] === firstSetFontArg0 &&
      argsArray[iFirstBeginText - 4][1] === firstSetFontArg1
    ) {
      count++;
      iFirst -= 5;
    }

    // Remove (endText, beginText, setFont) trios.
    let iEndText = iFirst + 4;
    for (let q = 1; q < count; q++) {
      fnArray.splice(iEndText, 3);
      argsArray.splice(iEndText, 3);
      iEndText += 2;
    }

    return iEndText + 1;
  }
);

// This replaces (save, transform, constructPath, restore)
// sequences with |constructPath| operation.
addState(
  InitialState,
  [OPS.save, OPS.transform, OPS.constructPath, OPS.restore],
  context => {
    const argsArray = context.argsArray;
    const iFirstConstructPath = context.iCurr - 1;
    const op = argsArray[iFirstConstructPath][0];

    // When stroking the transform has to be applied to the line width too.
    // So we can only optimize if the transform is an identity.
    if (
      op !== OPS.stroke &&
      op !== OPS.closeStroke &&
      op !== OPS.fillStroke &&
      op !== OPS.eoFillStroke &&
      op !== OPS.closeFillStroke &&
      op !== OPS.closeEOFillStroke
    ) {
      return true;
    }
    const iFirstTransform = context.iCurr - 2;
    const transform = argsArray[iFirstTransform];
    return (
      transform[0] === 1 &&
      transform[1] === 0 &&