Skip to content
This repository was archived by the owner on Jun 28, 2025. It is now read-only.

Commit b1c3826

Browse files
committed
Remove unneeded static initializer block
1 parent 13c44eb commit b1c3826

File tree

1 file changed

+17
-20
lines changed

1 file changed

+17
-20
lines changed

src/fast-string-array.ts

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
/**
2-
* Puts `key` into the backing array, if it is not already present. Returns
3-
* the index of the `key` in the backing array.
4-
*/
5-
export let put: (strarr: FastStringArray, key: string) => number;
6-
71
/**
82
* FastStringArray acts like a `Set` (allowing only one occurrence of a string
93
* `key`), but provides the index of the `key` in the backing array.
@@ -15,21 +9,24 @@ export let put: (strarr: FastStringArray, key: string) => number;
159
export class FastStringArray {
1610
indexes = Object.create(null) as { [key: string]: number };
1711
array = [] as ReadonlyArray<string>;
12+
}
1813

19-
static {
20-
put = (strarr, key) => {
21-
const { array, indexes } = strarr;
22-
// The key may or may not be present. If it is present, it's a number.
23-
let index = indexes[key] as number | undefined;
24-
25-
// If it's not yet present, we need to insert it and track the index in the
26-
// indexes.
27-
if (index === undefined) {
28-
index = indexes[key] = array.length;
29-
(array as string[]).push(key);
30-
}
14+
/**
15+
* Puts `key` into the backing array, if it is not already present. Returns
16+
* the index of the `key` in the backing array.
17+
*/
18+
export function put(strarr: FastStringArray, key: string): number {
19+
const { array, indexes } = strarr;
20+
// The key may or may not be present. If it is present, it's a number.
21+
let index = indexes[key] as number | undefined;
3122

32-
return index;
33-
};
23+
// If it's not yet present, we need to insert it and track the index in the
24+
// indexes.
25+
if (index === undefined) {
26+
index = indexes[key] = array.length;
27+
(array as string[]).push(key);
3428
}
29+
30+
return index;
3531
}
32+

0 commit comments

Comments
 (0)