diff options
author | cjihrig <cjihrig@gmail.com> | 2019-07-11 10:38:51 -0400 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2019-07-20 11:10:24 +0200 |
commit | 0383947ed7bd44fd4a80ef955ab70ef32363a634 (patch) | |
tree | 8a52d7a49f1ffbe7aa3b9f94da7925991392f5dc /lib | |
parent | dc734030fc8c1a0e34dc0ec20a475cb8806e4492 (diff) | |
download | android-node-v8-0383947ed7bd44fd4a80ef955ab70ef32363a634.tar.gz android-node-v8-0383947ed7bd44fd4a80ef955ab70ef32363a634.tar.bz2 android-node-v8-0383947ed7bd44fd4a80ef955ab70ef32363a634.zip |
readline: simplify isFullWidthCodePoint()
The non-ICU-based isFullWidthCodePoint() can be simplified to
a single `return` statement. This commit removes the extra
branching logic.
PR-URL: https://github.com/nodejs/node/pull/28640
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/internal/readline.js | 70 |
1 files changed, 30 insertions, 40 deletions
diff --git a/lib/internal/readline.js b/lib/internal/readline.js index c3f40c4fc4..c6cd13a6bd 100644 --- a/lib/internal/readline.js +++ b/lib/internal/readline.js @@ -82,48 +82,38 @@ if (internalBinding('config').hasIntl) { * Unicode code point is full-width. Otherwise returns false. */ isFullWidthCodePoint = function isFullWidthCodePoint(code) { - if (!Number.isInteger(code)) { - return false; - } - // Code points are derived from: // http://www.unicode.org/Public/UNIDATA/EastAsianWidth.txt - if ( - code >= 0x1100 && ( - code <= 0x115f || // Hangul Jamo - code === 0x2329 || // LEFT-POINTING ANGLE BRACKET - code === 0x232a || // RIGHT-POINTING ANGLE BRACKET - // CJK Radicals Supplement .. Enclosed CJK Letters and Months - code >= 0x2e80 && code <= 0x3247 && code !== 0x303f || - // Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A - code >= 0x3250 && code <= 0x4dbf || - // CJK Unified Ideographs .. Yi Radicals - code >= 0x4e00 && code <= 0xa4c6 || - // Hangul Jamo Extended-A - code >= 0xa960 && code <= 0xa97c || - // Hangul Syllables - code >= 0xac00 && code <= 0xd7a3 || - // CJK Compatibility Ideographs - code >= 0xf900 && code <= 0xfaff || - // Vertical Forms - code >= 0xfe10 && code <= 0xfe19 || - // CJK Compatibility Forms .. Small Form Variants - code >= 0xfe30 && code <= 0xfe6b || - // Halfwidth and Fullwidth Forms - code >= 0xff01 && code <= 0xff60 || - code >= 0xffe0 && code <= 0xffe6 || - // Kana Supplement - code >= 0x1b000 && code <= 0x1b001 || - // Enclosed Ideographic Supplement - code >= 0x1f200 && code <= 0x1f251 || - // CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane - code >= 0x20000 && code <= 0x3fffd - ) - ) { - return true; - } - - return false; + return Number.isInteger(code) && code >= 0x1100 && ( + code <= 0x115f || // Hangul Jamo + code === 0x2329 || // LEFT-POINTING ANGLE BRACKET + code === 0x232a || // RIGHT-POINTING ANGLE BRACKET + // CJK Radicals Supplement .. Enclosed CJK Letters and Months + code >= 0x2e80 && code <= 0x3247 && code !== 0x303f || + // Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A + code >= 0x3250 && code <= 0x4dbf || + // CJK Unified Ideographs .. Yi Radicals + code >= 0x4e00 && code <= 0xa4c6 || + // Hangul Jamo Extended-A + code >= 0xa960 && code <= 0xa97c || + // Hangul Syllables + code >= 0xac00 && code <= 0xd7a3 || + // CJK Compatibility Ideographs + code >= 0xf900 && code <= 0xfaff || + // Vertical Forms + code >= 0xfe10 && code <= 0xfe19 || + // CJK Compatibility Forms .. Small Form Variants + code >= 0xfe30 && code <= 0xfe6b || + // Halfwidth and Fullwidth Forms + code >= 0xff01 && code <= 0xff60 || + code >= 0xffe0 && code <= 0xffe6 || + // Kana Supplement + code >= 0x1b000 && code <= 0x1b001 || + // Enclosed Ideographic Supplement + code >= 0x1f200 && code <= 0x1f251 || + // CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane + code >= 0x20000 && code <= 0x3fffd + ); }; } |