mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-10 18:25:37 +02:00
Remove the isNum
helper function
The call-sites are replaced by direct `typeof`-checks instead, which removes unnecessary function calls. Note that in the `src/`-folder we already had more `typeof`-cases than `isNum`-calls. These changes were *mostly* done using regular expression search-and-replace, with two exceptions: - In `Font._charToGlyph` we no longer unconditionally update the `width`, since that seems completely unnecessary. - In `PDFDocument.documentInfo`, when parsing custom entries, we now do the `typeof`-check once.
This commit is contained in:
parent
edd024c9e7
commit
05edd91bdb
10 changed files with 30 additions and 51 deletions
|
@ -19,7 +19,6 @@ import {
|
|||
ImageKind,
|
||||
info,
|
||||
IsLittleEndianCached,
|
||||
isNum,
|
||||
OPS,
|
||||
shadow,
|
||||
TextRenderingMode,
|
||||
|
@ -2210,7 +2209,7 @@ class CanvasGraphics {
|
|||
i;
|
||||
for (i = 0; i < glyphsLength; ++i) {
|
||||
const glyph = glyphs[i];
|
||||
if (isNum(glyph)) {
|
||||
if (typeof glyph === "number") {
|
||||
x += (spacingDir * glyph * fontSize) / 1000;
|
||||
continue;
|
||||
}
|
||||
|
@ -2336,7 +2335,7 @@ class CanvasGraphics {
|
|||
|
||||
for (i = 0; i < glyphsLength; ++i) {
|
||||
glyph = glyphs[i];
|
||||
if (isNum(glyph)) {
|
||||
if (typeof glyph === "number") {
|
||||
spacingLength = (spacingDir * glyph * fontSize) / 1000;
|
||||
this.ctx.translate(spacingLength, 0);
|
||||
current.x += spacingLength * textHScale;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue