Skip to content

Commit 6061e58

Browse files
committed
return by emplace_back
Turns out it doesn't return void like push_back. Signed-off-by: Rosen Penev <[email protected]>
1 parent 494ca1d commit 6061e58

File tree

5 files changed

+7
-14
lines changed

5 files changed

+7
-14
lines changed

src/crwimage_int.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,7 @@ const CiffComponent::UniquePtr& CiffEntry::doAdd(UniquePtr /*component*/) {
134134
} // CiffEntry::doAdd
135135

136136
const CiffComponent::UniquePtr& CiffDirectory::doAdd(UniquePtr component) {
137-
components_.push_back(std::move(component));
138-
return components_.back();
137+
return components_.emplace_back(std::move(component));
139138
} // CiffDirectory::doAdd
140139

141140
void CiffHeader::read(const byte* pData, size_t size) {

src/exif.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -443,8 +443,7 @@ Exifdatum& ExifData::operator[](const std::string& key) {
443443
ExifKey exifKey(key);
444444
auto pos = findKey(exifKey);
445445
if (pos == end()) {
446-
exifMetadata_.emplace_back(exifKey);
447-
return exifMetadata_.back();
446+
return exifMetadata_.emplace_back(exifKey);
448447
}
449448
return *pos;
450449
}

src/iptc.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,7 @@ Iptcdatum& IptcData::operator[](const std::string& key) {
209209
IptcKey iptcKey(key);
210210
auto pos = findKey(iptcKey);
211211
if (pos == end()) {
212-
iptcMetadata_.emplace_back(iptcKey);
213-
return iptcMetadata_.back();
212+
return iptcMetadata_.emplace_back(iptcKey);
214213
}
215214
return *pos;
216215
}

src/tiffcomposite_int.cpp

+3-6
Original file line numberDiff line numberDiff line change
@@ -551,17 +551,15 @@ TiffComponent* TiffComponent::doAddChild(UniquePtr /*tiffComponent*/) {
551551
} // TiffComponent::doAddChild
552552

553553
TiffComponent* TiffDirectory::doAddChild(TiffComponent::UniquePtr tiffComponent) {
554-
components_.push_back(std::move(tiffComponent));
555-
return components_.back().get();
554+
return components_.emplace_back(std::move(tiffComponent)).get();
556555
} // TiffDirectory::doAddChild
557556

558557
TiffComponent* TiffSubIfd::doAddChild(TiffComponent::UniquePtr tiffComponent) {
559558
auto d = dynamic_cast<TiffDirectory*>(tiffComponent.release());
560559
if (!d) {
561560
throw Error(ErrorCode::kerErrorMessage, "dynamic_cast to TiffDirectory failed");
562561
}
563-
ifds_.emplace_back(d);
564-
return d;
562+
return ifds_.emplace_back(d).get();
565563
} // TiffSubIfd::doAddChild
566564

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

578576
TiffComponent* TiffBinaryArray::doAddChild(TiffComponent::UniquePtr tiffComponent) {
579-
elements_.push_back(std::move(tiffComponent));
580577
setDecoded(true);
581-
return elements_.back().get();
578+
return elements_.emplace_back(std::move(tiffComponent)).get();
582579
} // TiffBinaryArray::doAddChild
583580

584581
TiffComponent* TiffComponent::addNext(TiffComponent::UniquePtr tiffComponent) {

src/xmp.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -421,8 +421,7 @@ Xmpdatum& XmpData::operator[](const std::string& key) {
421421
XmpKey xmpKey(key);
422422
auto pos = findKey(xmpKey);
423423
if (pos == end()) {
424-
xmpMetadata_.emplace_back(xmpKey);
425-
return xmpMetadata_.back();
424+
return xmpMetadata_.emplace_back(xmpKey);
426425
}
427426
return *pos;
428427
}

0 commit comments

Comments
 (0)