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>
This commit is contained in:
cjihrig 2019-07-11 10:38:51 -04:00
parent 223ba43434
commit a13054549e
No known key found for this signature in database
GPG Key ID: 7434390BDBE9B9C5

View File

@ -82,14 +82,9 @@ 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 && (
return Number.isInteger(code) && code >= 0x1100 && (
code <= 0x115f || // Hangul Jamo
code === 0x2329 || // LEFT-POINTING ANGLE BRACKET
code === 0x232a || // RIGHT-POINTING ANGLE BRACKET
@ -118,12 +113,7 @@ if (internalBinding('config').hasIntl) {
code >= 0x1f200 && code <= 0x1f251 ||
// CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane
code >= 0x20000 && code <= 0x3fffd
)
) {
return true;
}
return false;
);
};
}