mirror of https://github.com/godotengine/godot
Merge pull request #76748 from KoBeWi/has_feature(fast)
Cache feature list in `OS.has_feature()`
This commit is contained in:
commit
fe6cd734ad
|
|
@ -423,7 +423,14 @@ Error OS::set_thread_name(const String &p_name) {
|
||||||
};
|
};
|
||||||
|
|
||||||
bool OS::has_feature(const String &p_feature) const {
|
bool OS::has_feature(const String &p_feature) const {
|
||||||
return ::OS::get_singleton()->has_feature(p_feature);
|
const bool *value_ptr = feature_cache.getptr(p_feature);
|
||||||
|
if (value_ptr) {
|
||||||
|
return *value_ptr;
|
||||||
|
} else {
|
||||||
|
const bool has = ::OS::get_singleton()->has_feature(p_feature);
|
||||||
|
feature_cache[p_feature] = has;
|
||||||
|
return has;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t OS::get_static_memory_usage() const {
|
uint64_t OS::get_static_memory_usage() const {
|
||||||
|
|
|
||||||
|
|
@ -119,6 +119,8 @@ public:
|
||||||
class OS : public Object {
|
class OS : public Object {
|
||||||
GDCLASS(OS, Object);
|
GDCLASS(OS, Object);
|
||||||
|
|
||||||
|
mutable HashMap<String, bool> feature_cache;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
static OS *singleton;
|
static OS *singleton;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue