From 3172098877ec94aed0020a1b30fea8dca04f14fe Mon Sep 17 00:00:00 2001 From: Justin King Date: Thu, 24 Sep 2026 14:58:25 -0700 Subject: [PATCH] Add CelMapClone. PiperOrigin-RevId: 987780926 --- eval/public/cel_value_clone.cc | 6 ++++++ eval/public/cel_value_clone.h | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/eval/public/cel_value_clone.cc b/eval/public/cel_value_clone.cc index 8a07033df..18c3cc422 100644 --- a/eval/public/cel_value_clone.cc +++ b/eval/public/cel_value_clone.cc @@ -163,4 +163,10 @@ absl::StatusOr CelValueClone(google::protobuf::Arena* arena, CelValue return in.Visit>(CloneVisitor{.arena = arena}); } +absl::StatusOr CelMapClone(google::protobuf::Arena* arena, + const CelMap* in) { + CEL_ASSIGN_OR_RETURN(CelValue out, CloneVisitor{.arena = arena}(in)); + return out.MapOrDie(); // Crash OK +} + } // namespace google::api::expr::runtime diff --git a/eval/public/cel_value_clone.h b/eval/public/cel_value_clone.h index 2ffe47894..cd98b0849 100644 --- a/eval/public/cel_value_clone.h +++ b/eval/public/cel_value_clone.h @@ -35,6 +35,12 @@ inline absl::StatusOr CelValueClone(google::protobuf::Arena* arena, return CelValueClone(arena, *in); } +// Clones (deep copy) a CelMap such that the resulting CelMap has a lifetime +// tied to the given arena. The container implementations for the output are not +// guaranteed to be the same as the input. +absl::StatusOr CelMapClone(google::protobuf::Arena* arena, + const CelMap* in); + } // namespace google::api::expr::runtime #endif // THIRD_PARTY_CEL_CPP_EVAL_PUBLIC_CEL_VALUE_CLONE_H_