This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 08a74241c5b [enhance](serde)update slice reserve and deduce slice back 
usage #29879
08a74241c5b is described below

commit 08a74241c5bb6dde7f9a742cebd76a157dbf46b7
Author: amory <wangqian...@selectdb.com>
AuthorDate: Fri Jan 12 21:40:31 2024 +0800

    [enhance](serde)update slice reserve and deduce slice back usage #29879
---
 be/src/vec/data_types/serde/data_type_array_serde.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/be/src/vec/data_types/serde/data_type_array_serde.cpp 
b/be/src/vec/data_types/serde/data_type_array_serde.cpp
index c372c46c0f0..15db808a641 100644
--- a/be/src/vec/data_types/serde/data_type_array_serde.cpp
+++ b/be/src/vec/data_types/serde/data_type_array_serde.cpp
@@ -105,6 +105,7 @@ Status 
DataTypeArraySerDe::deserialize_one_cell_from_json(IColumn& column, Slice
     int nested_level = 0;
     bool has_quote = false;
     std::vector<Slice> slices;
+    slices.reserve(10);
     slice.trim_prefix();
     slices.emplace_back(slice);
     size_t slice_size = slice.size;
@@ -126,9 +127,10 @@ Status 
DataTypeArraySerDe::deserialize_one_cell_from_json(IColumn& column, Slice
             --nested_level;
         } else if (!has_quote && nested_level == 0 && c == 
options.collection_delim) {
             // if meet collection_delimiter and not in quote, we can make it 
as an item.
-            slices.back().remove_suffix(slice_size - idx);
+            auto& last_slice = slices.back();
+            last_slice.remove_suffix(slice_size - idx);
             // we do not handle item in array is empty,just return error
-            if (slices.back().empty()) {
+            if (last_slice.empty()) {
                 return Status::InvalidArgument("here has item in Array({}) is 
empty!",
                                                slice.to_string());
             }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to