Skip to content

Commit

Permalink
Move SidebarItem instead of copying
Browse files Browse the repository at this point in the history
  • Loading branch information
simonhong committed Oct 3, 2022
1 parent 4a04170 commit 4b8cff4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions components/sidebar/sidebar_item.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ SidebarItem SidebarItem::Create(const GURL& url,
}

SidebarItem::SidebarItem() = default;
SidebarItem::SidebarItem(const SidebarItem&) = default;
SidebarItem& SidebarItem::operator=(const SidebarItem&) = default;
SidebarItem::SidebarItem(SidebarItem&&) = default;
SidebarItem& SidebarItem::operator=(SidebarItem&&) = default;

SidebarItem::~SidebarItem() = default;

Expand Down
4 changes: 4 additions & 0 deletions components/sidebar/sidebar_item.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ struct SidebarItem {
bool open_in_panel);

SidebarItem();
SidebarItem(const SidebarItem&);
SidebarItem& operator=(const SidebarItem&);
SidebarItem(SidebarItem&&);
SidebarItem& operator=(SidebarItem&&);
~SidebarItem();

bool operator==(const SidebarItem& item) const;
Expand Down
2 changes: 1 addition & 1 deletion components/sidebar/sidebar_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ std::vector<SidebarItem> SidebarService::GetDefaultSidebarItems() const {
for (const auto& item_type : SidebarService::kDefaultBuiltInItemTypes) {
if (auto item = GetBuiltInItemForType(item_type);
item.built_in_item_type != SidebarItem::BuiltInItemType::kNone) {
items.push_back(item);
items.push_back(std::move(item));
}
}
return items;
Expand Down

0 comments on commit 4b8cff4

Please sign in to comment.