mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-07 01:28:27 +08:00
enhance: optimize the performance of binary_search_string (#44470)
pr: #44469 Signed-off-by: sunby <sunbingyi1992@gmail.com>
This commit is contained in:
parent
8b0bfe4cd8
commit
c5a7845531
@ -180,10 +180,12 @@ class StringChunk : public Chunk {
|
|||||||
while (left <= right) {
|
while (left <= right) {
|
||||||
int mid = left + (right - left) / 2;
|
int mid = left + (right - left) / 2;
|
||||||
std::string_view midString = (*this)[mid];
|
std::string_view midString = (*this)[mid];
|
||||||
if (midString == target) {
|
auto cmp = midString.compare(target);
|
||||||
|
|
||||||
|
if (cmp == 0) {
|
||||||
result = mid; // Store the index of match
|
result = mid; // Store the index of match
|
||||||
right = mid - 1; // Continue searching in the left half
|
right = mid - 1; // Continue searching in the left half
|
||||||
} else if (midString < target) {
|
} else if (cmp < 0) {
|
||||||
// midString < target
|
// midString < target
|
||||||
left = mid + 1;
|
left = mid + 1;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user