From fa4c4d7b671cb4c10d830ec79a03edfd2a24f83c Mon Sep 17 00:00:00 2001 From: luofucong Date: Thu, 16 Jul 2026 10:57:39 +0800 Subject: [PATCH] x1 Signed-off-by: luofucong --- src/api/src/helper.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/api/src/helper.rs b/src/api/src/helper.rs index 4d661a372b..1067efcf92 100644 --- a/src/api/src/helper.rs +++ b/src/api/src/helper.rs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use std::collections::{BTreeMap, HashSet}; +use std::collections::HashSet; use std::sync::Arc; use common_decimal::Decimal128; @@ -1036,22 +1036,25 @@ fn decode_json_value_parts(value: &v1::JsonValue) -> (JsonVariant, JsonNativeTyp ) } json_value::Value::Object(object) => { - let mut variants = BTreeMap::new(); - let mut fields = BTreeMap::new(); + let mut variants = Vec::with_capacity(object.entries.len()); + let mut fields = Vec::with_capacity(object.entries.len()); for entry in &object.entries { let Some(value) = &entry.value else { continue; }; let (variant, json_type) = decode_json_value_parts(value); - variants.insert(entry.key.clone(), variant); - fields.insert(entry.key.clone(), json_type); + variants.push((entry.key.clone(), variant)); + fields.push((entry.key.clone(), json_type)); } let json_type = if fields.is_empty() { JsonNativeType::Null } else { - JsonNativeType::Object(fields) + JsonNativeType::Object(fields.into_iter().collect()) }; - (JsonVariant::Object(variants), json_type) + ( + JsonVariant::Object(variants.into_iter().collect()), + json_type, + ) } json_value::Value::Variant(x) => (JsonVariant::Variant(x.clone()), JsonNativeType::Variant), }