|
55 | 55 | * presence is relevant to determine whether a lookup needs to continue
|
56 | 56 | * looking or is done - buckets following a deleted element are shifted
|
57 | 57 | * backwards, unless they're empty or already at their optimal position.
|
| 58 | + * |
| 59 | + * Portions Copyright (c) 1996-2021, PostgreSQL Global Development Group |
| 60 | + * Portions Copyright (c) 1994, Regents of the University of California |
| 61 | + * |
| 62 | + * src/include/lib/simplehash.h |
58 | 63 | */
|
59 | 64 |
|
60 | 65 | #include "port/pg_bitutils.h"
|
@@ -218,7 +223,8 @@ SH_SCOPE void SH_STAT(SH_TYPE * tb);
|
218 | 223 | #define SIMPLEHASH_H
|
219 | 224 |
|
220 | 225 | #ifdef FRONTEND
|
221 |
| -#define sh_error(...) pg_log_error(__VA_ARGS__) |
| 226 | +#define sh_error(...) \ |
| 227 | + do { pg_log_fatal(__VA_ARGS__); exit(1); } while(0) |
222 | 228 | #define sh_log(...) pg_log_info(__VA_ARGS__)
|
223 | 229 | #else
|
224 | 230 | #define sh_error(...) elog(ERROR, __VA_ARGS__)
|
@@ -247,7 +253,7 @@ SH_COMPUTE_PARAMETERS(SH_TYPE * tb, uint64 newsize)
|
247 | 253 | * Verify that allocation of ->data is possible on this platform, without
|
248 | 254 | * overflowing Size.
|
249 | 255 | */
|
250 |
| - if ((((uint64) sizeof(SH_ELEMENT_TYPE)) * size) >= SIZE_MAX / 2) |
| 256 | + if (unlikely((((uint64) sizeof(SH_ELEMENT_TYPE)) * size) >= SIZE_MAX / 2)) |
251 | 257 | sh_error("hash table too large");
|
252 | 258 |
|
253 | 259 | /* now set size */
|
@@ -532,10 +538,8 @@ SH_INSERT_HASH_INTERNAL(SH_TYPE * tb, SH_KEY_TYPE key, uint32 hash, bool *found)
|
532 | 538 | */
|
533 | 539 | if (unlikely(tb->members >= tb->grow_threshold))
|
534 | 540 | {
|
535 |
| - if (tb->size == SH_MAX_SIZE) |
536 |
| - { |
| 541 | + if (unlikely(tb->size == SH_MAX_SIZE)) |
537 | 542 | sh_error("hash table size exceeded");
|
538 |
| - } |
539 | 543 |
|
540 | 544 | /*
|
541 | 545 | * When optimizing, it can be very useful to print these out.
|
|
0 commit comments