From 9baba00087bd8bdaf2d68ecbaad2b2352d20267a Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 11 Sep 2016 21:29:42 +0200 Subject: [PATCH] use mtype->key instead of repeated hashstring calls. --- src/util/crmessage.c | 4 ++-- src/util/nrmessage.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/util/crmessage.c b/src/util/crmessage.c index 98afe0f05..56f1e5dcd 100644 --- a/src/util/crmessage.c +++ b/src/util/crmessage.c @@ -81,7 +81,7 @@ static crmessage_type *crtypes[CRMAXHASH]; static crmessage_type *crt_find(const struct message_type *mtype) { - unsigned int hash = hashstring(mtype->name) % CRMAXHASH; + unsigned int hash = mtype->key % CRMAXHASH; crmessage_type *found = NULL; crmessage_type *type = crtypes[hash]; while (type) { @@ -94,7 +94,7 @@ static crmessage_type *crt_find(const struct message_type *mtype) void crt_register(const struct message_type *mtype) { - unsigned int hash = hashstring(mtype->name) % CRMAXHASH; + unsigned int hash = mtype->key % CRMAXHASH; crmessage_type *crt = crtypes[hash]; while (crt && crt->mtype != mtype) { crt = crt->next; diff --git a/src/util/nrmessage.c b/src/util/nrmessage.c index e3b0bcc0b..79638ec30 100644 --- a/src/util/nrmessage.c +++ b/src/util/nrmessage.c @@ -40,7 +40,7 @@ nrmessage_type *nrt_find(const struct locale * lang, const struct message_type * mtype) { nrmessage_type *found = NULL; - unsigned int hash = hashstring(mtype->name) % NRT_MAXHASH; + unsigned int hash = mtype->key % NRT_MAXHASH; nrmessage_type *type = nrtypes[hash]; while (type) { if (type->mtype == mtype) { @@ -101,7 +101,7 @@ void nrt_register(const struct message_type *mtype, const struct locale *lang, const char *string, int level, const char *section) { - unsigned int hash = hashstring(mtype->name) % NRT_MAXHASH; + unsigned int hash = mtype->key % NRT_MAXHASH; nrmessage_type *nrt = nrtypes[hash]; while (nrt && (nrt->lang != lang || nrt->mtype != mtype)) { nrt = nrt->next;