Revert "Optimize config_get_bool"

This reverts commit 1c38dc67c2.
This commit is contained in:
twinaphex 2020-06-25 12:08:36 +02:00
parent be49eb93e1
commit 35527c24c3
2 changed files with 13 additions and 30 deletions

View File

@ -448,23 +448,6 @@ static bool parse_line(config_file_t *conf,
return false;
}
if (
string_is_equal(list->value, "true")
|| string_is_equal(list->value, "1")
)
{
list->type = CONFIG_FILE_ENTRY_TYPE_BOOL;
list->value_bool = true;
}
else if (
string_is_equal(list->value, "false")
|| string_is_equal(list->value, "0")
)
{
list->type = CONFIG_FILE_ENTRY_TYPE_BOOL;
list->value_bool = false;
}
return true;
}
@ -928,13 +911,21 @@ bool config_get_bool(config_file_t *conf, const char *key, bool *in)
{
const struct config_entry_list *entry = config_get_entry(conf, key, NULL);
if (entry && entry->type == CONFIG_FILE_ENTRY_TYPE_BOOL)
if (entry)
{
*in = entry->value_bool;
return true;
if (string_is_equal(entry->value, "true"))
*in = true;
else if (string_is_equal(entry->value, "1"))
*in = true;
else if (string_is_equal(entry->value, "false"))
*in = false;
else if (string_is_equal(entry->value, "0"))
*in = false;
else
return false;
}
return false;
return entry != NULL;
}
void config_set_string(config_file_t *conf, const char *key, const char *val)

View File

@ -51,13 +51,6 @@ RETRO_BEGIN_DECLS
base->var = tmp; \
} while(0)
enum config_file_entry_type
{
CONFIG_FILE_ENTRY_TYPE_DONTCARE = 0,
CONFIG_FILE_ENTRY_TYPE_BOOL
};
struct config_file
{
char *path;
@ -127,11 +120,10 @@ struct config_entry_list
char *key;
char *value;
enum config_file_entry_type type;
bool value_bool;
struct config_entry_list *next;
};
struct config_file_entry
{
const char *key;