Skip to content

Commit

Permalink
Settings: Untested code for caching int/int32/double (not enabled)
Browse files Browse the repository at this point in the history
  • Loading branch information
kmatheussen committed Feb 7, 2024
1 parent 5cef21c commit 4bdd7d5
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions common/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,39 @@ void SETTINGS_write_bool(const char* key, bool val){
g_bools.put(key, val, val==true?"true":"false");
}

#if 0 // Untested code below. Probably works though.

static Cache<int64_t> g_ints;

int64_t SETTINGS_read_int(const char* key, int64_t def){
return g_ints.get(key, def, [](const char *string_val)
{
return atoll(string_val);
});
}

void SETTINGS_write_int(const char* key, int64_t val){
g_ints.put(key, val, QString::number(val);
}

int SETTINGS_read_int32(const char* key, int def){
return (int)SETTINGS_read_int(key, def);
}

static Cache<double> g_doubles;

double SETTINGS_read_double(const char* key, double def){
return g_doubles.get(key, def, [](const char *string_val)
{
return OS_get_double_from_string(string_val);
});
}

void SETTINGS_write_double(const char* key, double val){
g_doubles.put(key, val, OS_get_string_from_double(val));
}
#endif

int64_t SETTINGS_read_int(const char* key, int64_t def){
const char* val = SETTINGS_get_chars(key);

Expand Down

0 comments on commit 4bdd7d5

Please sign in to comment.