1
>
/*---------------------------------------------------------------------------------------------
characterClassifier.ts
2
>
* Copyright (c) Microsoft Corporation. All rights reserved.
3
>
* Licensed under the MIT License. See License.txt in the project root for license information.
4
>
*--------------------------------------------------------------------------------------------*/
5
>
6
>
import { toUint8 } from '../../../base/common/uint.js';
7
>
8
>
/**
9
>
* A fast character classifier that uses a compact array for ASCII values.
10
>
*/
11
>
export class CharacterClassifier<T extends number> {
12
>
/**
13
>
* Maintain a compact (fully initialized ASCII map for quickly classifying ASCII characters - used more often in code).
14
>
*/
15
>
protected readonly _asciiMap: Uint8Array;
16
>
17
>
/**
18
>
* The entire map (sparse array).
19
>
*/
20
>
protected readonly _map: Map<number, number>;
21
>
22
>
protected readonly _defaultValue: number;
23
>
24
>
constructor(_defaultValue: T) {
25
const defaultValue = toUint8(_defaultValue);
26