From 98748bce931f9dd6d19b0cb07a0cf7f34b4dcde9 Mon Sep 17 00:00:00 2001 From: Louis-Dominique Dubeau Date: Fri, 21 Jun 2019 19:56:17 -0400 Subject: [PATCH] perf: reorganize isChar for speed --- src/xml/1.0/ed5.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/xml/1.0/ed5.ts b/src/xml/1.0/ed5.ts index 06547e3..451d68f 100644 --- a/src/xml/1.0/ed5.ts +++ b/src/xml/1.0/ed5.ts @@ -55,12 +55,10 @@ export const S_LIST = [SPACE, NL, CR, TAB]; * @returns ``true`` if the codepoint matches ``CHAR``. */ export function isChar(c: number): boolean { - return (c === TAB || - c === NL || - c === CR || - (c >= SPACE && c <= 0xD7FF) || - (c >= 0xE000 && c <= 0xFFFD) || - (c >= 0x10000 && c <= 0x10FFFF)); + return (c > SPACE && c <= 0xD7FF) || + S_LIST.includes(c) || + (c >= 0xE000 && c <= 0xFFFD) || + (c >= 0x10000 && c <= 0x10FFFF); } /**