clang-tidy: don't use non const refs

Found with: google-runtime-references

Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
Rosen Penev 2023-03-03 22:29:19 -08:00
parent 01aab49f6f
commit d29001f2a4
3 changed files with 14 additions and 14 deletions

View File

@ -2004,9 +2004,10 @@ TiffComponent::UniquePtr TiffCreator::create(uint32_t extendedTag, IfdId group)
return nullptr;
} // TiffCreator::create
void TiffCreator::getPath(TiffPath& tiffPath, uint32_t extendedTag, IfdId group, uint32_t root) {
TiffPath TiffCreator::getPath(uint32_t extendedTag, IfdId group, uint32_t root) {
TiffPath ret;
while (true) {
tiffPath.emplace(extendedTag, group);
ret.emplace(extendedTag, group);
const auto ts = tiffTreeTable_.find(TiffGroupKey(root, group));
assert(ts != tiffTreeTable_.end());
extendedTag = ts->second.second;
@ -2015,6 +2016,7 @@ void TiffCreator::getPath(TiffPath& tiffPath, uint32_t extendedTag, IfdId group,
break;
}
}
return ret;
}
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
*/
WriteMethod writeMethod = wmIntrusive;
auto parsedTree = parse(pData, size, root, pHeader);
PrimaryGroups primaryGroups;
findPrimaryGroups(primaryGroups, parsedTree.get());
auto primaryGroups = findPrimaryGroups(parsedTree.get());
if (parsedTree) {
// Attempt to update existing TIFF components based on metadata entries
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,
} // TiffParserWorker::parse
void TiffParserWorker::findPrimaryGroups(PrimaryGroups& primaryGroups, TiffComponent* pSourceDir) {
PrimaryGroups TiffParserWorker::findPrimaryGroups(TiffComponent* pSourceDir) {
PrimaryGroups ret;
if (!pSourceDir)
return;
return ret;
static constexpr auto imageGroups = std::array{
IfdId::ifd0Id, IfdId::ifd1Id, IfdId::ifd2Id, IfdId::ifd3Id, IfdId::subImage1Id,
@ -2123,10 +2125,10 @@ void TiffParserWorker::findPrimaryGroups(PrimaryGroups& primaryGroups, TiffCompo
auto te = dynamic_cast<TiffEntryBase*>(finder.result());
const Value* pV = te ? te->pValue() : nullptr;
if (pV && pV->typeId() == unsignedLong && pV->count() == 1 && (pV->toInt64() & 1) == 0) {
primaryGroups.push_back(te->group());
ret.push_back(te->group());
}
}
return ret;
} // TiffParserWorker::findPrimaryGroups
TiffHeaderBase::TiffHeaderBase(uint16_t tag, uint32_t size, ByteOrder byteOrder, uint32_t offset) :

View File

@ -170,7 +170,7 @@ class TiffCreator {
the \em root TIFF element to the TIFF entry \em extendedTag and
\em group.
*/
static void getPath(TiffPath& tiffPath, uint32_t extendedTag, IfdId group, uint32_t root);
static TiffPath getPath(uint32_t extendedTag, IfdId group, uint32_t root);
private:
static const TiffTreeTable tiffTreeTable_; //<! TIFF tree structure
@ -244,7 +244,7 @@ class TiffParserWorker {
@param primaryGroups List of primary groups which is populated
@param pSourceDir Pointer to the source composite tree to search (may be 0)
*/
static void findPrimaryGroups(PrimaryGroups& primaryGroups, TiffComponent* pSourceDir);
static PrimaryGroups findPrimaryGroups(TiffComponent* pSourceDir);
}; // class TiffParserWorker

View File

@ -134,8 +134,7 @@ void TiffCopier::copyObject(const TiffComponent* object) {
if (pHeader_->isImageTag(object->tag(), object->group(), pPrimaryGroups_)) {
auto clone = object->clone();
// Assumption is that the corresponding TIFF entry doesn't exist
TiffPath tiffPath;
TiffCreator::getPath(tiffPath, object->tag(), object->group(), root_);
auto tiffPath = TiffCreator::getPath(object->tag(), object->group(), root_);
pRoot_->addPath(object->tag(), tiffPath, pRoot_, std::move(clone));
#ifdef EXIV2_DEBUG_MESSAGES
ExifKey key(object->tag(), groupName(object->group()));
@ -939,8 +938,7 @@ void TiffEncoder::add(TiffComponent* pRootDir, TiffComponent* pSourceDir, uint32
continue;
// Assumption is that the corresponding TIFF entry doesn't exist
TiffPath tiffPath;
TiffCreator::getPath(tiffPath, i->tag(), group, root);
auto tiffPath = TiffCreator::getPath(i->tag(), group, root);
TiffComponent* tc = pRootDir->addPath(i->tag(), tiffPath, pRootDir);
auto object = dynamic_cast<TiffEntryBase*>(tc);
#ifdef EXIV2_DEBUG_MESSAGES