Move bisect to Span and deduplicate code.

Co-authored-by: Lukas Tenbrink <lukas.tenbrink@gmail.com>
This commit is contained in:
Yufeng Ying 2025-05-13 22:49:20 +08:00
parent 09fcbb8645
commit 3bf400ffae
9 changed files with 113 additions and 108 deletions

View file

@ -34,7 +34,6 @@
#include "core/math/math_funcs.h"
#include "core/object/script_language.h"
#include "core/templates/hashfuncs.h"
#include "core/templates/search_array.h"
#include "core/templates/vector.h"
#include "core/variant/callable.h"
#include "core/variant/dictionary.h"
@ -737,8 +736,7 @@ void Array::shuffle() {
int Array::bsearch(const Variant &p_value, bool p_before) const {
Variant value = p_value;
ERR_FAIL_COND_V(!_p->typed.validate(value, "binary search"), -1);
SearchArray<Variant, _ArrayVariantSort> avs;
return avs.bisect(_p->array.ptr(), _p->array.size(), value, p_before);
return _p->array.span().bisect<_ArrayVariantSort>(value, p_before);
}
int Array::bsearch_custom(const Variant &p_value, const Callable &p_callable, bool p_before) const {