5
5
#include "config.h"
6
6
#include "strings.h"
7
7
#include "tree.h"
8
- #include "branch.h"
9
8
10
9
#ifdef INLINE_UNSIGNED
11
10
#include "unsigned.h"
@@ -132,26 +131,26 @@ bool strings_hash_seed(struct strings *strings, uint32_t seed) {
132
131
static tree_node_t * create_node (struct strings * strings , uint32_t hash ,
133
132
const char * string ) {
134
133
tree_node_t * node = block_alloc (strings -> index , sizeof (* node ));
135
- if (UNLIKELY ( !node ) ) {
134
+ if (!node ) {
136
135
return NULL ;
137
136
}
138
137
node -> hash = hash ;
139
138
node -> next = NULL ;
140
139
node -> id = strings -> total + 1 ;
141
- if (UNLIKELY ( node -> id == id_overflow ) ) {
140
+ if (node -> id == id_overflow ) {
142
141
return NULL ;
143
142
}
144
143
145
144
size_t len = strlen (string );
146
145
void * string_ptr = block_alloc (strings -> strings , len + 1 );
147
- if (UNLIKELY ( !string_ptr ) ) {
146
+ if (!string_ptr ) {
148
147
return NULL ;
149
148
}
150
149
memcpy (string_ptr , string , len + 1 );
151
150
node -> string = (const char * )string_ptr ;
152
151
153
152
uint32_t * hash_ptr = block_alloc (strings -> hashes , sizeof (* hash_ptr ));
154
- if (UNLIKELY ( !hash_ptr ) ) {
153
+ if (!hash_ptr ) {
155
154
return NULL ;
156
155
}
157
156
* hash_ptr = hash ;
@@ -174,7 +173,7 @@ static bool strings_intern_collision(struct strings *strings,
174
173
for (;;) {
175
174
if (!node -> next ) {
176
175
node = node -> next = create_node (strings , hash , string );
177
- if (UNLIKELY ( !node ) ) {
176
+ if (!node ) {
178
177
return 0 ;
179
178
}
180
179
break ;
@@ -195,7 +194,7 @@ uint32_t strings_intern(struct strings *strings, const char *string) {
195
194
#ifdef INLINE_UNSIGNED
196
195
if (is_small_unsigned (string )) {
197
196
uint32_t number = to_unsigned (string );
198
- if (LIKELY ( number < unsigned_tag ) ) {
197
+ if (number < unsigned_tag ) {
199
198
return number | unsigned_tag ;
200
199
}
201
200
}
@@ -204,11 +203,11 @@ uint32_t strings_intern(struct strings *strings, const char *string) {
204
203
uint32_t hash = strings_hash (strings , string );
205
204
tree_node_t * node = find_node (strings , hash );
206
205
if (node ) {
207
- if (UNLIKELY ( strcmp (node -> string , string ) )) {
206
+ if (strcmp (node -> string , string )) {
208
207
return strings_intern_collision (strings , node , string , hash );
209
208
}
210
209
} else {
211
- if (UNLIKELY ( !(node = create_node (strings , hash , string ) ))) {
210
+ if (!(node = create_node (strings , hash , string ))) {
212
211
return 0 ;
213
212
}
214
213
tree_insert (& strings -> hash_map , node );
@@ -221,7 +220,7 @@ uint32_t strings_lookup(const struct strings *strings, const char *string) {
221
220
#ifdef INLINE_UNSIGNED
222
221
if (is_small_unsigned (string )) {
223
222
uint32_t number = to_unsigned (string );
224
- if (LIKELY ( number < unsigned_tag ) ) {
223
+ if (number < unsigned_tag ) {
225
224
return number | unsigned_tag ;
226
225
}
227
226
}
@@ -231,7 +230,7 @@ uint32_t strings_lookup(const struct strings *strings, const char *string) {
231
230
tree_node_t * node = find_node (strings , hash );
232
231
if (node ) {
233
232
do {
234
- if (LIKELY ( !strcmp (node -> string , string ) )) {
233
+ if (!strcmp (node -> string , string )) {
235
234
return node -> id ;
236
235
}
237
236
} while ((node = node -> next ));
@@ -248,7 +247,7 @@ const char *strings_lookup_id(struct strings *strings, uint32_t id) {
248
247
}
249
248
#endif
250
249
251
- if (UNLIKELY ( id > strings -> total ) ) {
250
+ if (id > strings -> total ) {
252
251
return NULL ;
253
252
}
254
253
@@ -262,7 +261,7 @@ const char *strings_lookup_id(struct strings *strings, uint32_t id) {
262
261
263
262
tree_node_t * node = find_node (strings , hash );
264
263
do {
265
- if (LIKELY ( node -> id == id ) ) {
264
+ if (node -> id == id ) {
266
265
return node -> string ;
267
266
}
268
267
} while ((node = node -> next ));
@@ -280,16 +279,16 @@ void strings_cursor_init(struct strings_cursor *cursor,
280
279
281
280
bool strings_cursor_next (struct strings_cursor * cursor ) {
282
281
const struct block * block = cursor -> strings ;
283
- if (LIKELY ( cursor -> id ) ) {
282
+ if (cursor -> id ) {
284
283
const char * string = strings_cursor_string (cursor );
285
284
cursor -> offset += strlen (string ) + 1 ;
286
- if (UNLIKELY ( cursor -> offset >= block -> offsets [cursor -> page ]) ) {
285
+ if (cursor -> offset >= block -> offsets [cursor -> page ]) {
287
286
cursor -> page ++ ;
288
287
cursor -> offset = 0 ;
289
288
}
290
289
}
291
- if (UNLIKELY ( cursor -> page >= block -> count ||
292
- cursor -> offset >= block -> offsets [cursor -> page ])) {
290
+ if (cursor -> page >= block -> count ||
291
+ cursor -> offset >= block -> offsets [cursor -> page ]) {
293
292
cursor -> id = 0 ;
294
293
return false;
295
294
}
@@ -298,7 +297,7 @@ bool strings_cursor_next(struct strings_cursor *cursor) {
298
297
}
299
298
300
299
const char * strings_cursor_string (const struct strings_cursor * cursor ) {
301
- if (UNLIKELY ( !cursor -> id ) ) {
300
+ if (!cursor -> id ) {
302
301
return NULL ;
303
302
}
304
303
const void * page = cursor -> strings -> pages [cursor -> page ];
@@ -338,7 +337,7 @@ bool strings_restore(struct strings *strings,
338
337
offset += sizeof (tree_node_t )) {
339
338
node = (tree_node_t * )((uintptr_t )block -> pages [page ] + offset );
340
339
existing = find_node (strings , node -> hash );
341
- if (UNLIKELY ( existing ) ) {
340
+ if (existing ) {
342
341
while (existing -> next ) {
343
342
existing = existing -> next ;
344
343
}
0 commit comments