1313
1414// @ts -check
1515
16- import { searchUnicodeRange } from './core.js' ;
16+ import { findUnicodeRangeIndex } from './core.js' ;
1717import { isBMP } from './utils.js' ;
1818import { GraphemeCategory , grapheme_ranges } from './_grapheme_data.js' ;
1919import { consonant_ranges } from './_incb_data.js' ;
@@ -45,8 +45,11 @@ export {
4545 * @return A {@link GraphemeCategoryRange} value if found, or garbage value with {@link GC_Any} category.
4646 */
4747export function searchGraphemeCategory ( cp ) {
48- let range = searchUnicodeRange ( cp , grapheme_ranges ) ;
49- return range || [ 0 , 0 , 0 /* GC_Any */ ] ;
48+ let index = findUnicodeRangeIndex ( cp , grapheme_ranges ) ;
49+ if ( index < 0 ) {
50+ return [ 0 , 0 , 0 /* GC_Any */ ] ;
51+ }
52+ return grapheme_ranges [ index ] ;
5053}
5154
5255/**
@@ -245,10 +248,11 @@ function cat(cp, cache) {
245248 // If this char isn't within the cached range, update the cache to the
246249 // range that includes it.
247250 if ( cp < cache [ 0 ] || cp > cache [ 1 ] ) {
248- let range = searchUnicodeRange ( cp , grapheme_ranges ) ;
249- if ( ! range ) {
251+ let index = findUnicodeRangeIndex ( cp , grapheme_ranges ) ;
252+ if ( index < 0 ) {
250253 return 0 ;
251254 }
255+ let range = grapheme_ranges [ index ] ;
252256 cache [ 0 ] = range [ 0 ] ;
253257 cache [ 1 ] = range [ 1 ] ;
254258 cache [ 2 ] = range [ 2 ] ;
@@ -262,7 +266,7 @@ function cat(cp, cache) {
262266 * @return {boolean }
263267 */
264268function isIndicConjunctCosonant ( cp ) {
265- return searchUnicodeRange ( cp , consonant_ranges ) !== null ;
269+ return findUnicodeRangeIndex ( cp , consonant_ranges ) >= 0 ;
266270}
267271
268272/**
0 commit comments