Skip to content

Commit

Permalink
Refactor getCount method to improve logic by consolidating validation…
Browse files Browse the repository at this point in the history
… checks into a single conditional statement.
  • Loading branch information
przemek83 committed Jan 3, 2025
1 parent 7fa30f9 commit d049a62
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/ImportXlsx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,18 +222,14 @@ std::pair<bool, int> ImportXlsx::getCount(const QString& sheetName,
const QHash<QString, int>& countMap)
{
if (const auto it{countMap.find(sheetName)}; it != countMap.end())
return {true, it.value()};

if (!isCommonDataOk())
return {false, {}};

if (!isSheetNameValid(getSheetNames().second, sheetName))
return {false, {}};
return {true, *it};

if (!analyzeSheet(sheetName))
return {false, 0};
if (isCommonDataOk() &&
isSheetNameValid(getSheetNames().second, sheetName) &&
analyzeSheet(sheetName))
return {true, countMap.find(sheetName).value()};

return {true, countMap.find(sheetName).value()};
return {false, {}};
}

std::pair<bool, QDomNodeList> ImportXlsx::getSheetNodes(
Expand Down

0 comments on commit d049a62

Please sign in to comment.