forked from github/server
Mit einem Hashtable nrt_find beschleunigt.
Ausführungszeit ist durch die beiden letzten Änderungen von 26:44 minuten auf 15:25 minuten gesunken, was schon ein echt spürbarer Fortschritt ist. Weitere Optimierungskandidaten: 19.80 116.74 116.74 8791 13.28 17.58 firstregion 11.56 184.90 68.16 7275 9.37 16.38 lastregion 7.28 227.80 42.90 644401018 0.00 0.00 a_find 6.81 267.97 40.17 856647 0.05 0.07 internal_path_find 4.57 294.90 26.93 1055956 0.03 0.03 mt_find 3.33 314.51 19.61 263723185 0.00 0.00 check_leuchtturm
This commit is contained in:
parent
18cfe8b9a0
commit
0f2f7f7b62
|
@ -20,17 +20,15 @@
|
||||||
#include "message.h"
|
#include "message.h"
|
||||||
#include "language.h"
|
#include "language.h"
|
||||||
#include "translation.h"
|
#include "translation.h"
|
||||||
|
#include "goodies.h"
|
||||||
|
|
||||||
/* libc includes */
|
/* libc includes */
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
static nrmessage_type * messagetypes;
|
#define NRT_MAXHASH 256
|
||||||
|
static nrmessage_type * messagetypes[NRT_MAXHASH];
|
||||||
nrmessage_type * get_nrmessagetypes(void) {
|
|
||||||
return messagetypes;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
nrt_string(const struct nrmessage_type *type)
|
nrt_string(const struct nrmessage_type *type)
|
||||||
|
@ -42,7 +40,8 @@ nrmessage_type *
|
||||||
nrt_find(const struct locale * lang, const struct message_type * mtype)
|
nrt_find(const struct locale * lang, const struct message_type * mtype)
|
||||||
{
|
{
|
||||||
nrmessage_type * found = NULL;
|
nrmessage_type * found = NULL;
|
||||||
nrmessage_type * type = messagetypes;
|
unsigned int hash = hashstring(mtype->name) % NRT_MAXHASH;
|
||||||
|
nrmessage_type * type = messagetypes[hash];
|
||||||
while (type) {
|
while (type) {
|
||||||
if (type->mtype==mtype) {
|
if (type->mtype==mtype) {
|
||||||
if (found==NULL) found = type;
|
if (found==NULL) found = type;
|
||||||
|
@ -60,7 +59,8 @@ nrt_find(const struct locale * lang, const struct message_type * mtype)
|
||||||
void
|
void
|
||||||
nrt_register(const struct message_type * mtype, const struct locale * lang, const char * string, int level, const char * section)
|
nrt_register(const struct message_type * mtype, const struct locale * lang, const char * string, int level, const char * section)
|
||||||
{
|
{
|
||||||
nrmessage_type * nrt = messagetypes;
|
unsigned int hash = hashstring(mtype->name) % NRT_MAXHASH;
|
||||||
|
nrmessage_type * nrt = messagetypes[hash];
|
||||||
while (nrt && (nrt->lang!=lang || nrt->mtype!=mtype)) {
|
while (nrt && (nrt->lang!=lang || nrt->mtype!=mtype)) {
|
||||||
nrt = nrt->next;
|
nrt = nrt->next;
|
||||||
}
|
}
|
||||||
|
@ -71,11 +71,11 @@ nrt_register(const struct message_type * mtype, const struct locale * lang, cons
|
||||||
nrt = malloc(sizeof(nrmessage_type));
|
nrt = malloc(sizeof(nrmessage_type));
|
||||||
nrt->lang = lang;
|
nrt->lang = lang;
|
||||||
nrt->mtype = mtype;
|
nrt->mtype = mtype;
|
||||||
nrt->next = messagetypes;
|
nrt->next = messagetypes[hash];
|
||||||
nrt->level=level;
|
nrt->level=level;
|
||||||
if (section) nrt->section = strdup(section);
|
if (section) nrt->section = strdup(section);
|
||||||
else nrt->section = NULL;
|
else nrt->section = NULL;
|
||||||
messagetypes = nrt;
|
messagetypes[hash] = nrt;
|
||||||
assert(string && *string);
|
assert(string && *string);
|
||||||
nrt->string = strdup(string);
|
nrt->string = strdup(string);
|
||||||
*c = '\0';
|
*c = '\0';
|
||||||
|
|
Loading…
Reference in New Issue