Update vector.h
using non-templated neares_power_of_2
This commit is contained in:
parent
5d63f4e758
commit
3a390e9b44
1 changed files with 3 additions and 2 deletions
|
@ -70,7 +70,8 @@ class Vector {
|
||||||
}
|
}
|
||||||
|
|
||||||
_FORCE_INLINE_ size_t _get_alloc_size(size_t p_elements) const {
|
_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 {
|
_FORCE_INLINE_ bool _get_alloc_size_checked(size_t p_elements, size_t *out) const {
|
||||||
|
@ -79,7 +80,7 @@ class Vector {
|
||||||
size_t p;
|
size_t p;
|
||||||
if (_mul_overflow(p_elements, sizeof(T), &o)) return false;
|
if (_mul_overflow(p_elements, sizeof(T), &o)) return false;
|
||||||
if (_add_overflow(o, sizeof(SafeRefCount)+sizeof(int), &p)) 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;
|
return true;
|
||||||
#else
|
#else
|
||||||
// Speed is more important than correctness here, do the operations unchecked
|
// Speed is more important than correctness here, do the operations unchecked
|
||||||
|
|
Loading…
Reference in a new issue