diff options
Diffstat (limited to 'core')
| -rw-r--r-- | core/dictionary.cpp | 10 | ||||
| -rw-r--r-- | core/dictionary.h | 2 | ||||
| -rw-r--r-- | core/variant_call.cpp | 2 | ||||
| -rw-r--r-- | core/vector.h | 5 |
4 files changed, 17 insertions, 2 deletions
diff --git a/core/dictionary.cpp b/core/dictionary.cpp index a013c21b29..75c8531251 100644 --- a/core/dictionary.cpp +++ b/core/dictionary.cpp @@ -110,6 +110,16 @@ bool Dictionary::has(const Variant& p_key) const { return _p->variant_map.has(p_key); } + +bool Dictionary::has_all(const Array& p_keys) const { + for (int i=0;i<p_keys.size();i++) { + if( !has(p_keys[i]) ) { + return false; + } + } + return true; +} + void Dictionary::erase(const Variant& p_key) { _copy_on_write(); _p->variant_map.erase(p_key); diff --git a/core/dictionary.h b/core/dictionary.h index 145e7e5c84..c854e95ee6 100644 --- a/core/dictionary.h +++ b/core/dictionary.h @@ -69,6 +69,8 @@ public: bool is_shared() const; bool has(const Variant& p_key) const; + bool has_all(const Array& p_keys) const; + void erase(const Variant& p_key); bool operator==(const Dictionary& p_dictionary) const; diff --git a/core/variant_call.cpp b/core/variant_call.cpp index 78814c83e2..a4963f0d1f 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -440,6 +440,7 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var VCALL_LOCALMEM0R(Dictionary,empty); VCALL_LOCALMEM0(Dictionary,clear); VCALL_LOCALMEM1R(Dictionary,has); + VCALL_LOCALMEM1R(Dictionary,has_all); VCALL_LOCALMEM1(Dictionary,erase); VCALL_LOCALMEM0R(Dictionary,hash); VCALL_LOCALMEM0R(Dictionary,keys); @@ -1423,6 +1424,7 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl ADDFUNC0(DICTIONARY,BOOL,Dictionary,empty,varray()); ADDFUNC0(DICTIONARY,NIL,Dictionary,clear,varray()); ADDFUNC1(DICTIONARY,BOOL,Dictionary,has,NIL,"value",varray()); + ADDFUNC1(DICTIONARY,BOOL,Dictionary,has_all,ARRAY,"values",varray()); ADDFUNC1(DICTIONARY,NIL,Dictionary,erase,NIL,"value",varray()); ADDFUNC0(DICTIONARY,INT,Dictionary,hash,varray()); ADDFUNC0(DICTIONARY,ARRAY,Dictionary,keys,varray()); diff --git a/core/vector.h b/core/vector.h index 16a09c1ddd..87248ccf68 100644 --- a/core/vector.h +++ b/core/vector.h @@ -70,7 +70,8 @@ class Vector { } _FORCE_INLINE_ size_t _get_alloc_size(size_t p_elements) const { - return nearest_power_of_2_templated(p_elements*sizeof(T)+sizeof(SafeRefCount)+sizeof(int)); + //return nearest_power_of_2_templated(p_elements*sizeof(T)+sizeof(SafeRefCount)+sizeof(int)); + return nearest_power_of_2(p_elements*sizeof(T)+sizeof(SafeRefCount)+sizeof(int)); } _FORCE_INLINE_ bool _get_alloc_size_checked(size_t p_elements, size_t *out) const { @@ -79,7 +80,7 @@ class Vector { size_t p; if (_mul_overflow(p_elements, sizeof(T), &o)) return false; if (_add_overflow(o, sizeof(SafeRefCount)+sizeof(int), &p)) return false; - *out = nearest_power_of_2_templated(p); + *out = nearest_power_of_2(p); return true; #else // Speed is more important than correctness here, do the operations unchecked |