diff --git a/src/Dictionaries/CacheDictionary.cpp b/src/Dictionaries/CacheDictionary.cpp index 39186f0d63f..4dfe802dd2b 100644 --- a/src/Dictionaries/CacheDictionary.cpp +++ b/src/Dictionaries/CacheDictionary.cpp @@ -487,25 +487,21 @@ template Pipe CacheDictionary::read(const Names & column_names, size_t max_block_size) const { Pipe pipe; - + std::optional data; { /// Write lock on storage const ProfilingScopedWriteRWLock write_lock{rw_lock, ProfileEvents::DictCacheLockWriteNs}; if constexpr (dictionary_key_type == DictionaryKeyType::simple) - pipe = Pipe(std::make_shared( - DictionarySourceData(shared_from_this(), cache_storage_ptr->getCachedSimpleKeys(), column_names), - max_block_size)); + data.emplace(shared_from_this(), cache_storage_ptr->getCachedSimpleKeys(), column_names); else { auto keys = cache_storage_ptr->getCachedComplexKeys(); - pipe = Pipe(std::make_shared( - DictionarySourceData(shared_from_this(), keys, column_names), - max_block_size)); + data.emplace(shared_from_this(), keys, column_names); } } - return pipe; + return Pipe(std::make_shared(std::move(*data), max_block_size)); } template