Skip to content

Commit 139dab5

Browse files
committed
s/tree_nodes/index/
1 parent 60e6c56 commit 139dab5

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

strings.c

+13-13
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ rb_gen(static, tree_, tree_t, tree_node_t, tree_link, tree_cmp)
6161
struct strings {
6262
struct block *hashes;
6363
struct block *strings;
64-
struct block *tree_nodes;
64+
struct block *index;
6565
tree_t hash_map;
6666
uint32_t total;
6767
uint32_t hash_seed;
@@ -78,8 +78,8 @@ struct strings *strings_new() {
7878

7979
strings->hashes = block_new(PAGE_SIZE);
8080
strings->strings = block_new(PAGE_SIZE);
81-
strings->tree_nodes = block_new(PAGE_SIZE);
82-
if (!strings->hashes || !strings->strings || !strings->tree_nodes) {
81+
strings->index = block_new(PAGE_SIZE);
82+
if (!strings->hashes || !strings->strings || !strings->index) {
8383
goto error;
8484
}
8585

@@ -97,8 +97,8 @@ struct strings *strings_new() {
9797
if (strings->strings) {
9898
block_free(strings->strings);
9999
}
100-
if (strings->tree_nodes) {
101-
block_free(strings->tree_nodes);
100+
if (strings->index) {
101+
block_free(strings->index);
102102
}
103103
free(strings);
104104
return NULL;
@@ -107,7 +107,7 @@ struct strings *strings_new() {
107107
void strings_free(struct strings *strings) {
108108
block_free(strings->hashes);
109109
block_free(strings->strings);
110-
block_free(strings->tree_nodes);
110+
block_free(strings->index);
111111
free(strings);
112112
}
113113

@@ -131,7 +131,7 @@ bool strings_hash_seed(struct strings *strings, uint32_t seed) {
131131

132132
static tree_node_t *create_node(struct strings *strings, uint32_t hash,
133133
const char *string) {
134-
tree_node_t *node = block_alloc(strings->tree_nodes, sizeof(*node));
134+
tree_node_t *node = block_alloc(strings->index, sizeof(*node));
135135
if (UNLIKELY(!node)) {
136136
return NULL;
137137
}
@@ -313,21 +313,21 @@ void strings_snapshot(const struct strings *strings,
313313
struct strings_snapshot *snapshot) {
314314
block_snapshot(strings->strings, &snapshot->strings);
315315
block_snapshot(strings->hashes, &snapshot->hashes);
316-
block_snapshot(strings->tree_nodes, &snapshot->tree_nodes);
316+
block_snapshot(strings->index, &snapshot->index);
317317
snapshot->total = strings->total;
318318
}
319319

320320
bool strings_restore(struct strings *strings,
321321
const struct strings_snapshot *snapshot) {
322-
struct block *block = strings->tree_nodes;
323-
if (snapshot->tree_nodes.count == block->count &&
324-
snapshot->tree_nodes.offset == block->offsets[block->count - 1]) {
322+
struct block *block = strings->index;
323+
if (snapshot->index.count == block->count &&
324+
snapshot->index.offset == block->offsets[block->count - 1]) {
325325
return true;
326326
}
327327

328328
if (!block_restore(strings->strings, &snapshot->strings) ||
329329
!block_restore(strings->hashes, &snapshot->hashes) ||
330-
!block_restore(strings->tree_nodes, &snapshot->tree_nodes)) {
330+
!block_restore(strings->index, &snapshot->index)) {
331331
return false;
332332
}
333333
strings->total = snapshot->total;
@@ -354,7 +354,7 @@ bool strings_restore(struct strings *strings,
354354
size_t strings_allocated_bytes(const struct strings *strings) {
355355
return block_allocated_bytes(strings->strings) +
356356
block_allocated_bytes(strings->hashes) +
357-
block_allocated_bytes(strings->tree_nodes) +
357+
block_allocated_bytes(strings->index) +
358358
sizeof(*strings);
359359
}
360360

strings.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ uint32_t strings_cursor_id(const struct strings_cursor*);
5555
struct strings_snapshot {
5656
struct block_snapshot strings;
5757
struct block_snapshot hashes;
58-
struct block_snapshot tree_nodes;
58+
struct block_snapshot index;
5959
uint32_t total;
6060
};
6161

0 commit comments

Comments
 (0)