From bd5293b798ce3b9944d94cb3013243de0114eba6 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Fri, 14 Jun 2024 09:35:00 +0900 Subject: [PATCH] Fix copy constructor For the wrong code written in anticipation of the order of the bundle, the elements are taken out of the list and the values are copied. This patc is for backward compatibility. Change-Id: I77eb340fcac5e0b4e7fbe8946cf4bdadfc44e576 Signed-off-by: Hwankyu Jhun --- src/bundle/bundle-internal.cc | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/bundle/bundle-internal.cc b/src/bundle/bundle-internal.cc index 68ccd8e..0470413 100644 --- a/src/bundle/bundle-internal.cc +++ b/src/bundle/bundle-internal.cc @@ -53,10 +53,9 @@ Bundle::Bundle(int argc, char** argv) { } Bundle::Bundle(const Bundle& b) { - for (const auto& [key, val] : b.map_) { - const KeyInfo& info = *val; - auto new_val = std::make_shared(info); - map_[key] = new_val; + for (const auto& info : b.list_) { + auto new_val = std::make_shared(*info); + map_[info->GetKey()] = new_val; list_.push_back(std::move(new_val)); } } @@ -65,10 +64,9 @@ Bundle& Bundle::operator = (const Bundle& b) { if (this != &b) { map_.clear(); list_.clear(); - for (const auto& [key, val] : b.map_) { - const KeyInfo& info = *val; - auto new_val = std::make_shared(info); - map_[key] = new_val; + for (const auto& info : b.list_) { + auto new_val = std::make_shared(*info); + map_[info->GetKey()] = new_val; list_.push_back(std::move(new_val)); } } -- 2.7.4