1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-25 09:38:06 +02:00

Remove the isBool helper function

The call-sites are replaced by direct `typeof`-checks instead, which removes unnecessary function calls.
This commit is contained in:
Jonas Jenwald 2022-02-23 12:25:13 +01:00
parent 82f1ee1755
commit 3704283f5b
4 changed files with 6 additions and 30 deletions

View file

@ -17,7 +17,6 @@ import { Dict, Ref } from "./primitives.js";
import {
FormatError,
info,
isBool,
IsEvalSupportedCached,
shadow,
unreachable,
@ -627,7 +626,7 @@ class PostScriptEvaluator {
case "and":
b = stack.pop();
a = stack.pop();
if (isBool(a) && isBool(b)) {
if (typeof a === "boolean" && typeof b === "boolean") {
stack.push(a && b);
} else {
stack.push(a & b);
@ -751,7 +750,7 @@ class PostScriptEvaluator {
break;
case "not":
a = stack.pop();
if (isBool(a)) {
if (typeof a === "boolean") {
stack.push(!a);
} else {
stack.push(~a);
@ -760,7 +759,7 @@ class PostScriptEvaluator {
case "or":
b = stack.pop();
a = stack.pop();
if (isBool(a) && isBool(b)) {
if (typeof a === "boolean" && typeof b === "boolean") {
stack.push(a || b);
} else {
stack.push(a | b);
@ -802,7 +801,7 @@ class PostScriptEvaluator {
case "xor":
b = stack.pop();
a = stack.pop();
if (isBool(a) && isBool(b)) {
if (typeof a === "boolean" && typeof b === "boolean") {
stack.push(a !== b);
} else {
stack.push(a ^ b);