Skip to content

Commit d29001f

Browse files
committed
clang-tidy: don't use non const refs
Found with: google-runtime-references Signed-off-by: Rosen Penev <[email protected]>
1 parent 01aab49 commit d29001f

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

src/tiffimage_int.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2004,9 +2004,10 @@ TiffComponent::UniquePtr TiffCreator::create(uint32_t extendedTag, IfdId group)
20042004
return nullptr;
20052005
} // TiffCreator::create
20062006

2007-
void TiffCreator::getPath(TiffPath& tiffPath, uint32_t extendedTag, IfdId group, uint32_t root) {
2007+
TiffPath TiffCreator::getPath(uint32_t extendedTag, IfdId group, uint32_t root) {
2008+
TiffPath ret;
20082009
while (true) {
2009-
tiffPath.emplace(extendedTag, group);
2010+
ret.emplace(extendedTag, group);
20102011
const auto ts = tiffTreeTable_.find(TiffGroupKey(root, group));
20112012
assert(ts != tiffTreeTable_.end());
20122013
extendedTag = ts->second.second;
@@ -2015,6 +2016,7 @@ void TiffCreator::getPath(TiffPath& tiffPath, uint32_t extendedTag, IfdId group,
20152016
break;
20162017
}
20172018
}
2019+
return ret;
20182020
}
20192021

20202022
ByteOrder TiffParserWorker::decode(ExifData& exifData, IptcData& iptcData, XmpData& xmpData, const byte* pData,
@@ -2047,8 +2049,7 @@ WriteMethod TiffParserWorker::encode(BasicIo& io, const byte* pData, size_t size
20472049
*/
20482050
WriteMethod writeMethod = wmIntrusive;
20492051
auto parsedTree = parse(pData, size, root, pHeader);
2050-
PrimaryGroups primaryGroups;
2051-
findPrimaryGroups(primaryGroups, parsedTree.get());
2052+
auto primaryGroups = findPrimaryGroups(parsedTree.get());
20522053
if (parsedTree) {
20532054
// Attempt to update existing TIFF components based on metadata entries
20542055
TiffEncoder encoder(exifData, iptcData, xmpData, parsedTree.get(), false, &primaryGroups, pHeader, findEncoderFct);
@@ -2107,9 +2108,10 @@ TiffComponent::UniquePtr TiffParserWorker::parse(const byte* pData, size_t size,
21072108

21082109
} // TiffParserWorker::parse
21092110

2110-
void TiffParserWorker::findPrimaryGroups(PrimaryGroups& primaryGroups, TiffComponent* pSourceDir) {
2111+
PrimaryGroups TiffParserWorker::findPrimaryGroups(TiffComponent* pSourceDir) {
2112+
PrimaryGroups ret;
21112113
if (!pSourceDir)
2112-
return;
2114+
return ret;
21132115

21142116
static constexpr auto imageGroups = std::array{
21152117
IfdId::ifd0Id, IfdId::ifd1Id, IfdId::ifd2Id, IfdId::ifd3Id, IfdId::subImage1Id,
@@ -2123,10 +2125,10 @@ void TiffParserWorker::findPrimaryGroups(PrimaryGroups& primaryGroups, TiffCompo
21232125
auto te = dynamic_cast<TiffEntryBase*>(finder.result());
21242126
const Value* pV = te ? te->pValue() : nullptr;
21252127
if (pV && pV->typeId() == unsignedLong && pV->count() == 1 && (pV->toInt64() & 1) == 0) {
2126-
primaryGroups.push_back(te->group());
2128+
ret.push_back(te->group());
21272129
}
21282130
}
2129-
2131+
return ret;
21302132
} // TiffParserWorker::findPrimaryGroups
21312133

21322134
TiffHeaderBase::TiffHeaderBase(uint16_t tag, uint32_t size, ByteOrder byteOrder, uint32_t offset) :

src/tiffimage_int.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ class TiffCreator {
170170
the \em root TIFF element to the TIFF entry \em extendedTag and
171171
\em group.
172172
*/
173-
static void getPath(TiffPath& tiffPath, uint32_t extendedTag, IfdId group, uint32_t root);
173+
static TiffPath getPath(uint32_t extendedTag, IfdId group, uint32_t root);
174174

175175
private:
176176
static const TiffTreeTable tiffTreeTable_; //<! TIFF tree structure
@@ -244,7 +244,7 @@ class TiffParserWorker {
244244
@param primaryGroups List of primary groups which is populated
245245
@param pSourceDir Pointer to the source composite tree to search (may be 0)
246246
*/
247-
static void findPrimaryGroups(PrimaryGroups& primaryGroups, TiffComponent* pSourceDir);
247+
static PrimaryGroups findPrimaryGroups(TiffComponent* pSourceDir);
248248

249249
}; // class TiffParserWorker
250250

src/tiffvisitor_int.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,7 @@ void TiffCopier::copyObject(const TiffComponent* object) {
134134
if (pHeader_->isImageTag(object->tag(), object->group(), pPrimaryGroups_)) {
135135
auto clone = object->clone();
136136
// Assumption is that the corresponding TIFF entry doesn't exist
137-
TiffPath tiffPath;
138-
TiffCreator::getPath(tiffPath, object->tag(), object->group(), root_);
137+
auto tiffPath = TiffCreator::getPath(object->tag(), object->group(), root_);
139138
pRoot_->addPath(object->tag(), tiffPath, pRoot_, std::move(clone));
140139
#ifdef EXIV2_DEBUG_MESSAGES
141140
ExifKey key(object->tag(), groupName(object->group()));
@@ -939,8 +938,7 @@ void TiffEncoder::add(TiffComponent* pRootDir, TiffComponent* pSourceDir, uint32
939938
continue;
940939

941940
// Assumption is that the corresponding TIFF entry doesn't exist
942-
TiffPath tiffPath;
943-
TiffCreator::getPath(tiffPath, i->tag(), group, root);
941+
auto tiffPath = TiffCreator::getPath(i->tag(), group, root);
944942
TiffComponent* tc = pRootDir->addPath(i->tag(), tiffPath, pRootDir);
945943
auto object = dynamic_cast<TiffEntryBase*>(tc);
946944
#ifdef EXIV2_DEBUG_MESSAGES

0 commit comments

Comments
 (0)