From be2e6e0d9361e844c39bb3e48a3777db0ef52f67 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sun, 22 Dec 2019 15:46:23 -0500 Subject: Optimize jpIsKanji and jpIsKana --- ext/mixed/js/japanese.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ext/mixed/js/japanese.js b/ext/mixed/js/japanese.js index 26349094..44db4b8c 100644 --- a/ext/mixed/js/japanese.js +++ b/ext/mixed/js/japanese.js @@ -78,11 +78,18 @@ const jpHalfWidthCharacterMapping = new Map([ function jpIsKanji(c) { const code = c.charCodeAt(0); - return code >= 0x4e00 && code < 0x9fb0 || code >= 0x3400 && code < 0x4dc0; + return ( + (code >= 0x4e00 && code < 0x9fb0) || + (code >= 0x3400 && code < 0x4dc0) + ); } function jpIsKana(c) { - return wanakana.isKana(c); + const code = c.charCodeAt(0); + return ( + (code >= 0x3041 && code <= 0x3096) || // hiragana + (code >= 0x30a1 && code <= 0x30fc) // katakana + ); } function jpIsJapaneseText(text) { -- cgit v1.2.3