summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/config.h4
-rw-r--r--include/pttstruct.h5
-rw-r--r--mbbsd/cache.c7
3 files changed, 9 insertions, 7 deletions
diff --git a/include/config.h b/include/config.h
index 14b14d03..5b562c10 100644
--- a/include/config.h
+++ b/include/config.h
@@ -121,6 +121,10 @@
#define ADD_EXMAILBOX 0 /* 贈送信箱 */
#endif
+#ifndef HASH_BITS
+#define HASH_BITS 16 /* userid->uid hashing bits */
+#endif
+
/* more.c 中文章頁數上限(lines/22), +4 for safe */
#define MAX_PAGES (MAX_EDIT_LINE / 22 + 4)
diff --git a/include/pttstruct.h b/include/pttstruct.h
index 26eacc51..e0259c40 100644
--- a/include/pttstruct.h
+++ b/include/pttstruct.h
@@ -280,10 +280,6 @@ typedef struct fileheader_t {
#define STRLEN 80 /* Length of most string data */
-/* uhash is a userid->uid hash table -- jochang */
-
-#define HASH_BITS 16
-
union xitem_t {
struct { /* bbs_item */
char fdate[9]; /* [mm/dd/yy] */
@@ -466,6 +462,7 @@ typedef struct keeploc_t {
typedef struct {
int version;
/* uhash */
+ /* uhash is a userid->uid hash table -- jochang */
char userid[MAX_USERS][IDLEN + 1];
char gap_1[IDLEN+1];
int next_in_hash[MAX_USERS];
diff --git a/mbbsd/cache.c b/mbbsd/cache.c
index 4345e282..493b9b91 100644
--- a/mbbsd/cache.c
+++ b/mbbsd/cache.c
@@ -150,9 +150,6 @@ add_to_uhash(int n, char *id)
int *p, h = StringHash(id)%(1<<HASH_BITS);
int times;
strlcpy(SHM->userid[n], id, sizeof(SHM->userid[n]));
-#if (1<<HASH_BITS)*2 < MAX_USERS
-#error "HASH_BITS too small"
-#endif
p = &(SHM->hash_head[h]);
@@ -186,6 +183,10 @@ remove_from_uhash(int n)
*p = SHM->next_in_hash[n];
}
+#if (1<<HASH_BITS)*10 < MAX_USERS
+#warning "Suggest to use bigger HASH_BITS for better searchuser() performance,"
+#warning "searchuser() average chaining MAX_USERS/(1<<HASH_BITS) times."
+#endif
int
searchuser(char *userid)
{