mirror of
https://github.com/postgres/postgres.git
synced 2025-11-01 21:31:19 +03:00
Convert uses of hash_string_pointer to fasthash equivalent
Remove duplicate hash_string_pointer() function definitions by creating a new inline function hash_string() for this purpose. This has the added advantage of avoiding strlen() calls when doing hash lookup. It's not clear how many of these are perfomance-sensitive enough to benefit from that, but the simplification is worth it on its own. Reviewed by Jeff Davis Discussion: https://postgr.es/m/CANWCAZbg_XeSeY0a_PqWmWqeRATvzTzUNYRLeT%2Bbzs%2BYQdC92g%40mail.gmail.com
This commit is contained in:
@@ -28,7 +28,7 @@
|
||||
|
||||
#include "catalog/pg_tablespace_d.h"
|
||||
#include "common/file_utils.h"
|
||||
#include "common/hashfn.h"
|
||||
#include "common/hashfn_unstable.h"
|
||||
#include "common/string.h"
|
||||
#include "datapagemap.h"
|
||||
#include "filemap.h"
|
||||
@@ -38,12 +38,11 @@
|
||||
* Define a hash table which we can use to store information about the files
|
||||
* appearing in source and target systems.
|
||||
*/
|
||||
static uint32 hash_string_pointer(const char *s);
|
||||
#define SH_PREFIX filehash
|
||||
#define SH_ELEMENT_TYPE file_entry_t
|
||||
#define SH_KEY_TYPE const char *
|
||||
#define SH_KEY path
|
||||
#define SH_HASH_KEY(tb, key) hash_string_pointer(key)
|
||||
#define SH_HASH_KEY(tb, key) hash_string(key)
|
||||
#define SH_EQUAL(tb, a, b) (strcmp(a, b) == 0)
|
||||
#define SH_SCOPE static inline
|
||||
#define SH_RAW_ALLOCATOR pg_malloc0
|
||||
@@ -821,15 +820,3 @@ decide_file_actions(void)
|
||||
|
||||
return filemap;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Helper function for filemap hash table.
|
||||
*/
|
||||
static uint32
|
||||
hash_string_pointer(const char *s)
|
||||
{
|
||||
unsigned char *ss = (unsigned char *) s;
|
||||
|
||||
return hash_bytes(ss, strlen(s));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user