From 16e1d8bbb7a58d67595b7338c357f9dd69bc6db8 Mon Sep 17 00:00:00 2001 From: Kevin Backhouse Date: Fri, 31 Jan 2025 11:37:18 +0000 Subject: [PATCH] Refactoring suggested by @neheb (cherry picked from commit 03bdced43ac2a5f93ea549e6b262185eb904b581) # Conflicts: # src/crwimage_int.cpp --- src/crwimage_int.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/crwimage_int.cpp b/src/crwimage_int.cpp index 5c0fbc92dd..3120a9aad1 100644 --- a/src/crwimage_int.cpp +++ b/src/crwimage_int.cpp @@ -566,6 +566,7 @@ CiffComponent* CiffDirectory::doAdd(CrwDirs& crwDirs, uint16_t crwTagId) { add(std::move(m_)); } // Recursive call to next lower level directory +<<<<<<< HEAD cc = cc->add(crwDirs, crwTagId); } else { // Find the tag @@ -587,7 +588,22 @@ CiffComponent* CiffDirectory::doAdd(CrwDirs& crwDirs, uint16_t crwTagId) { m_ = std::make_unique(crwTagId, tag()); cc = m_.get(); add(std::move(m_)); +======= + return cc->add(crwDirs, crwTagId); + } + + // Find the tag + for (const auto& c : components_) + if (c->tagId() == crwTagId) { + cc = c; + break; +>>>>>>> 03bdced4 (Refactoring suggested by @neheb) } + if (!cc) { + // Tag doesn't exist yet, add it + m_ = std::make_unique(crwTagId, tag()); + cc = m_.get(); + add(std::move(m_)); } return cc; } // CiffDirectory::doAdd