MCPcopy Create free account
hub / github.com/cel-expr/cel-cpp / operator[]

Method operator[]

eval/public/containers/internal_field_backed_map_impl.cc:148–169  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

146}
147
148absl::optional<CelValue> FieldBackedMapImpl::operator[](CelValue key) const {
149 // Fast implementation which uses a friend method to do a hash-based key
150 // lookup.
151 MapValueConstRef value_ref;
152 auto lookup_result = LookupMapValue(key, &value_ref);
153 if (!lookup_result.ok()) {
154 return CreateErrorValue(arena_, lookup_result.status());
155 }
156 if (!*lookup_result) {
157 return absl::nullopt;
158 }
159
160 // Get value descriptor treating it as a repeated field.
161 // All values in protobuf map have the same type.
162 // The map is not empty, because LookupMapValue returned true.
163 absl::StatusOr<CelValue> result = CreateValueFromMapValue(
164 message_, value_desc_, &value_ref, factory_, arena_);
165 if (!result.ok()) {
166 return CreateErrorValue(arena_, result.status());
167 }
168 return *result;
169}
170
171absl::StatusOr<bool> FieldBackedMapImpl::LookupMapValue(
172 const CelValue& key, MapValueConstRef* value_ref) const {

Callers

nothing calls this directly

Calls 4

CreateErrorValueFunction · 0.85
CreateValueFromMapValueFunction · 0.70
LookupMapValueFunction · 0.50
okMethod · 0.45

Tested by

no test coverage detected