| 146 | } |
| 147 | |
| 148 | absl::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 | |
| 171 | absl::StatusOr<bool> FieldBackedMapImpl::LookupMapValue( |
| 172 | const CelValue& key, MapValueConstRef* value_ref) const { |
nothing calls this directly
no test coverage detected