From 181893d31a7c4057557f420154dd95930f62ce77 Mon Sep 17 00:00:00 2001 From: Veloman Yunkan Date: Mon, 4 Mar 2024 17:33:21 +0400 Subject: [PATCH] Cleanup after previous change - Got rid of the continue statement - Renamed the function parameter - Fixed indentation --- src/name_mapper.cpp | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/name_mapper.cpp b/src/name_mapper.cpp index 56844cc04..88daed5b0 100644 --- a/src/name_mapper.cpp +++ b/src/name_mapper.cpp @@ -35,26 +35,24 @@ HumanReadableNameMapper::HumanReadableNameMapper(kiwix::Library& library, bool w continue; auto aliasName = replaceRegex(bookName, "", "_[[:digit:]]{4}-[[:digit:]]{2}$"); - if (aliasName == bookName) { - continue; + if (aliasName != bookName) { + mapName(library, aliasName, bookId); } - - mapName(library, aliasName, bookId); } } -void HumanReadableNameMapper::mapName(const Library& library, std::string aliasName, std::string bookId) { - if (m_nameToId.find(aliasName) == m_nameToId.end()) { - m_nameToId[aliasName] = bookId; - } else { - const auto& currentBook = library.getBookById(bookId); - auto alreadyPresentPath = library.getBookById(m_nameToId[aliasName]).getPath(); - std::cerr << "Path collision: " << alreadyPresentPath - << " and " << currentBook.getPath() - << " can't share the same URL path '" << aliasName << "'." - << " Therefore, only " << alreadyPresentPath - << " will be served." << std::endl; - } +void HumanReadableNameMapper::mapName(const Library& library, std::string name, std::string bookId) { + if (m_nameToId.find(name) == m_nameToId.end()) { + m_nameToId[name] = bookId; + } else { + const auto& currentBook = library.getBookById(bookId); + auto alreadyPresentPath = library.getBookById(m_nameToId[name]).getPath(); + std::cerr << "Path collision: " << alreadyPresentPath + << " and " << currentBook.getPath() + << " can't share the same URL path '" << name << "'." + << " Therefore, only " << alreadyPresentPath + << " will be served." << std::endl; + } } std::string HumanReadableNameMapper::getNameForId(const std::string& id) const {