|
86 | 86 | * presence is relevant to determine whether a lookup needs to continue
|
87 | 87 | * looking or is done - buckets following a deleted element are shifted
|
88 | 88 | * backwards, unless they're empty or already at their optimal position.
|
| 89 | + * |
| 90 | + * Portions Copyright (c) 1996-2021, PostgreSQL Global Development Group |
| 91 | + * Portions Copyright (c) 1994, Regents of the University of California |
| 92 | + * |
| 93 | + * src/include/lib/simplehash.h |
89 | 94 | */
|
90 | 95 |
|
91 | 96 | #include "port/pg_bitutils.h"
|
@@ -288,7 +293,8 @@ SH_SCOPE void SH_STAT(SH_TYPE * tb);
|
288 | 293 | #define SIMPLEHASH_H
|
289 | 294 |
|
290 | 295 | #ifdef FRONTEND
|
291 |
| -#define sh_error(...) pg_log_error(__VA_ARGS__) |
| 296 | +#define sh_error(...) \ |
| 297 | + do { pg_log_fatal(__VA_ARGS__); exit(1); } while(0) |
292 | 298 | #define sh_log(...) pg_log_info(__VA_ARGS__)
|
293 | 299 | #else
|
294 | 300 | #define sh_error(...) elog(ERROR, __VA_ARGS__)
|
@@ -317,7 +323,7 @@ SH_COMPUTE_PARAMETERS(SH_TYPE * tb, uint64 newsize)
|
317 | 323 | * Verify that allocation of ->data is possible on this platform, without
|
318 | 324 | * overflowing Size.
|
319 | 325 | */
|
320 |
| - if ((((uint64) sizeof(SH_ELEMENT_TYPE)) * size) >= SIZE_MAX / 2) |
| 326 | + if (unlikely((((uint64) sizeof(SH_ELEMENT_TYPE)) * size) >= SIZE_MAX / 2)) |
321 | 327 | sh_error("hash table too large");
|
322 | 328 |
|
323 | 329 | /* now set size */
|
@@ -602,10 +608,8 @@ SH_INSERT_HASH_INTERNAL(SH_TYPE * tb, SH_KEY_TYPE key, uint32 hash, bool *found)
|
602 | 608 | */
|
603 | 609 | if (unlikely(tb->members >= tb->grow_threshold))
|
604 | 610 | {
|
605 |
| - if (tb->size == SH_MAX_SIZE) |
606 |
| - { |
| 611 | + if (unlikely(tb->size == SH_MAX_SIZE)) |
607 | 612 | sh_error("hash table size exceeded");
|
608 |
| - } |
609 | 613 |
|
610 | 614 | /*
|
611 | 615 | * When optimizing, it can be very useful to print these out.
|
|
0 commit comments