Line | Branch | Exec | Source |
---|---|---|---|
1 | #include "intern.h" | ||
2 | #include "hashset.h" | ||
3 | |||
4 | // NOLINTNEXTLINE(*-avoid-non-const-global-variables) | ||
5 | static HashSet interned_strings; | ||
6 | |||
7 | 1128 | const void *mem_intern(const void *data, size_t len) | |
8 | { | ||
9 |
2/2✓ Branch 0 taken 8 times.
✓ Branch 1 taken 1120 times.
|
1128 | if (unlikely(interned_strings.table_size == 0)) { |
10 | 8 | hashset_init(&interned_strings, 32, false); | |
11 | } | ||
12 | |||
13 | 1128 | HashSetEntry *e = hashset_insert(&interned_strings, data, len); | |
14 | 1128 | return e->str; | |
15 | } | ||
16 | |||
17 | 8 | void free_interned_strings(void) | |
18 | { | ||
19 | 8 | hashset_free(&interned_strings); | |
20 | 8 | } | |
21 |