Skip to content

return by emplace_back #3226

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/crwimage_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,7 @@ const CiffComponent::UniquePtr& CiffEntry::doAdd(UniquePtr /*component*/) {
} // CiffEntry::doAdd

const CiffComponent::UniquePtr& CiffDirectory::doAdd(UniquePtr component) {
components_.push_back(std::move(component));
return components_.back();
return components_.emplace_back(std::move(component));
} // CiffDirectory::doAdd

void CiffHeader::read(const byte* pData, size_t size) {
Expand Down
3 changes: 1 addition & 2 deletions src/exif.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,7 @@ Exifdatum& ExifData::operator[](const std::string& key) {
ExifKey exifKey(key);
auto pos = findKey(exifKey);
if (pos == end()) {
exifMetadata_.emplace_back(exifKey);
return exifMetadata_.back();
return exifMetadata_.emplace_back(exifKey);
}
return *pos;
}
Expand Down
3 changes: 1 addition & 2 deletions src/iptc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,7 @@ Iptcdatum& IptcData::operator[](const std::string& key) {
IptcKey iptcKey(key);
auto pos = findKey(iptcKey);
if (pos == end()) {
iptcMetadata_.emplace_back(iptcKey);
return iptcMetadata_.back();
return iptcMetadata_.emplace_back(iptcKey);
}
return *pos;
}
Expand Down
9 changes: 3 additions & 6 deletions src/tiffcomposite_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -551,17 +551,15 @@ TiffComponent* TiffComponent::doAddChild(UniquePtr /*tiffComponent*/) {
} // TiffComponent::doAddChild

TiffComponent* TiffDirectory::doAddChild(TiffComponent::UniquePtr tiffComponent) {
components_.push_back(std::move(tiffComponent));
return components_.back().get();
return components_.emplace_back(std::move(tiffComponent)).get();
} // TiffDirectory::doAddChild

TiffComponent* TiffSubIfd::doAddChild(TiffComponent::UniquePtr tiffComponent) {
auto d = dynamic_cast<TiffDirectory*>(tiffComponent.release());
if (!d) {
throw Error(ErrorCode::kerErrorMessage, "dynamic_cast to TiffDirectory failed");
}
ifds_.emplace_back(d);
return d;
return ifds_.emplace_back(d).get();
} // TiffSubIfd::doAddChild

TiffComponent* TiffMnEntry::doAddChild(TiffComponent::UniquePtr tiffComponent) {
Expand All @@ -576,9 +574,8 @@ TiffComponent* TiffIfdMakernote::doAddChild(TiffComponent::UniquePtr tiffCompone
}

TiffComponent* TiffBinaryArray::doAddChild(TiffComponent::UniquePtr tiffComponent) {
elements_.push_back(std::move(tiffComponent));
setDecoded(true);
return elements_.back().get();
return elements_.emplace_back(std::move(tiffComponent)).get();
} // TiffBinaryArray::doAddChild

TiffComponent* TiffComponent::addNext(TiffComponent::UniquePtr tiffComponent) {
Expand Down
3 changes: 1 addition & 2 deletions src/xmp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,8 +421,7 @@ Xmpdatum& XmpData::operator[](const std::string& key) {
XmpKey xmpKey(key);
auto pos = findKey(xmpKey);
if (pos == end()) {
xmpMetadata_.emplace_back(xmpKey);
return xmpMetadata_.back();
return xmpMetadata_.emplace_back(xmpKey);
}
return *pos;
}
Expand Down
Loading