Skip to content

Commit

Permalink
Remove unnecessary clone following the key segment pair refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
poodlewars committed Feb 7, 2025
1 parent 25e4a07 commit 1478b04
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions cpp/arcticdb/async/tasks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,18 +397,9 @@ struct CopyCompressedInterStoreTask : async::BaseTask {
key_segment_pair.set_key(*key_to_write_);
}

for (auto it = target_stores_.begin(); it != target_stores_.end(); ++it) {
auto& target_store = *it;
for (auto& target_store : target_stores_) {
try {
auto key_segment_pair_copy = key_segment_pair;
if (it != std::prev(target_stores_.end())) {
// If this is not the last target we want to do a deep copy because write_compressed_sync will
// move out of the underlying segment.
auto key_copy = key_segment_pair.variant_key();
auto segment_copy = key_segment_pair.segment().clone();
key_segment_pair_copy = storage::KeySegmentPair(std::move(key_copy), std::move(segment_copy));
}
target_store->write_compressed_sync(key_segment_pair_copy);
target_store->write_compressed_sync(key_segment_pair);
} catch (const storage::DuplicateKeyException& e) {
log::storage().debug("Key {} already exists on the target: {}", variant_key_view(key_to_read_), e.what());
} catch (const std::exception& e) {
Expand Down

0 comments on commit 1478b04

Please sign in to comment.