@@ -38,12 +38,16 @@ template <typename AttributeType, typename OutputType, typename DefaultGetter>
3838void CacheDictionary::getItemsNumberImpl (
3939 Attribute & attribute, const PaddedPODArray<Key> & ids, ResultArrayType<OutputType> & out, DefaultGetter && get_default) const
4040{
41+ // / First fill everything with default values
42+ const auto rows = ext::size (ids);
43+ for (const auto row : ext::range (0 , rows))
44+ out[row] = get_default (row);
45+
4146 // / Mapping: <id> -> { all indices `i` of `ids` such that `ids[i]` = <id> }
4247 std::unordered_map<Key, std::vector<size_t >> cache_expired_ids;
4348 std::unordered_map<Key, std::vector<size_t >> cache_not_found_ids;
4449
4550 auto & attribute_array = std::get<ContainerPtrType<AttributeType>>(attribute.arrays );
46- const auto rows = ext::size (ids);
4751
4852 size_t cache_hit = 0 ;
4953
@@ -67,7 +71,8 @@ void CacheDictionary::getItemsNumberImpl(
6771 {
6872 const auto & cell_idx = find_result.cell_idx ;
6973 const auto & cell = cells[cell_idx];
70- out[row] = cell.isDefault () ? get_default (row) : static_cast <OutputType>(attribute_array[cell_idx]);
74+ if (!cell.isDefault ())
75+ out[row] = static_cast <OutputType>(attribute_array[cell_idx]);
7176 };
7277
7378 if (!find_result.valid )
@@ -154,14 +159,7 @@ void CacheDictionary::getItemsNumberImpl(
154159 out[row] = static_cast <OutputType>(attribute_value);
155160 };
156161
157- auto on_id_not_found = [&] (const auto id, const auto )
158- {
159- for (const size_t row : cache_not_found_ids[id])
160- out[row] = get_default (row);
161-
162- for (const size_t row : cache_expired_ids[id])
163- out[row] = get_default (row);
164- };
162+ auto on_id_not_found = [&] (auto , auto ) {};
165163
166164 // / Request new values
167165 auto update_unit_ptr = std::make_shared<UpdateUnit>(required_ids, on_cell_updated, on_id_not_found);
0 commit comments