Get rid of hashes in config_file.c

This commit is contained in:
twinaphex 2017-12-11 11:40:36 +01:00
parent c950613098
commit e1461cc0de
2 changed files with 7 additions and 22 deletions

View File

@ -44,7 +44,6 @@
#include <file/file_path.h>
#include <lists/string_list.h>
#include <string/stdstring.h>
#include <rhash.h>
#include <streams/file_stream.h>
#define MAX_INCLUDE_DEPTH 16
@ -54,7 +53,6 @@ struct config_entry_list
/* If we got this from an #include,
* do not allow overwrite. */
bool readonly;
uint32_t key_hash;
char *key;
char *value;
@ -313,11 +311,11 @@ static bool parse_line(config_file_t *conf,
key[idx++] = *line++;
}
key[idx] = '\0';
list->key = key;
list->key_hash = djb2_calculate(key);
key[idx] = '\0';
list->key = key;
list->value = extract_value(line, true);
list->value = extract_value(line, true);
if (!list->value)
{
list->key = NULL;
@ -378,7 +376,6 @@ static config_file_t *config_file_new_internal(
}
list->readonly = false;
list->key_hash = 0;
list->key = NULL;
list->value = NULL;
list->next = NULL;
@ -510,7 +507,6 @@ config_file_t *config_file_new_from_string(const char *from_string)
}
list->readonly = false;
list->key_hash = 0;
list->key = NULL;
list->value = NULL;
list->next = NULL;
@ -545,17 +541,12 @@ config_file_t *config_file_new(const char *path)
static struct config_entry_list *config_get_entry(const config_file_t *conf,
const char *key, struct config_entry_list **prev)
{
struct config_entry_list *entry;
struct config_entry_list *previous = NULL;
uint32_t hash = djb2_calculate(key);
if (prev)
previous = *prev;
struct config_entry_list *entry = NULL;
struct config_entry_list *previous = prev ? *prev : NULL;
for (entry = conf->entries; entry; entry = entry->next)
{
if (hash == entry->key_hash && string_is_equal(key, entry->key))
if (string_is_equal(key, entry->key))
return entry;
previous = entry;
@ -775,7 +766,6 @@ void config_set_string(config_file_t *conf, const char *key, const char *val)
return;
entry->readonly = false;
entry->key_hash = 0;
entry->key = strdup(key);
entry->value = strdup(val);
entry->next = NULL;

View File

@ -100,11 +100,6 @@ int filestream_printf(RFILE *stream, const char* format, ...);
int filestream_error(RFILE *stream);
/* DO NOT put these functions back, unless you want to deal with
the UNAVOIDABLE REGRESSIONS on platforms using unexpected rfile backends
int filestream_get_fd(RFILE *stream);
FILE* filestream_get_fp(RFILE *stream); */
int filestream_flush(RFILE *stream);
static INLINE char *filestream_getline(RFILE *stream)