From: Holger Schemel Date: Mon, 19 Dec 2016 20:24:47 +0000 (+0100) Subject: improved performance of artwork config initialization (InitArtworkConfig) X-Git-Tag: 4.0.0.0~4 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=14a9d030139b185b174f538e1ac8f027182c521c;p=rocksndiamonds.git improved performance of artwork config initialization (InitArtworkConfig) --- diff --git a/src/libgame/misc.c b/src/libgame/misc.c index 0ea2d07a..559fd385 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -2795,12 +2795,18 @@ struct FileInfo *getFileListFromConfigList(struct ConfigInfo *config_list, char **ignore_tokens, int num_file_list_entries) { + SetupFileHash *ignore_tokens_hash; struct FileInfo *file_list; int num_file_list_entries_found = 0; int num_suffix_list_entries = 0; int list_pos; int i, j; + /* create hash from list of tokens to be ignored (for quick access) */ + ignore_tokens_hash = newSetupFileHash(); + for (i = 0; ignore_tokens[i] != NULL; i++) + setHashEntry(ignore_tokens_hash, ignore_tokens[i], ""); + file_list = checked_calloc(num_file_list_entries * sizeof(struct FileInfo)); for (i = 0; suffix_list[i].token != NULL; i++) @@ -2858,9 +2864,8 @@ struct FileInfo *getFileListFromConfigList(struct ConfigInfo *config_list, } /* the following tokens are no file definitions, but other config tokens */ - for (j = 0; ignore_tokens[j] != NULL; j++) - if (strEqual(config_list[i].token, ignore_tokens[j])) - is_file_entry = FALSE; + if (getHashEntry(ignore_tokens_hash, config_list[i].token) != NULL) + is_file_entry = FALSE; if (is_file_entry) { @@ -2890,6 +2895,8 @@ struct FileInfo *getFileListFromConfigList(struct ConfigInfo *config_list, Error(ERR_EXIT, "please fix"); } + freeSetupFileHash(ignore_tokens_hash); + return file_list; }