From ce991188f39c657487bbda88ce450bc9c641248b Mon Sep 17 00:00:00 2001 From: Alex Turbov Date: Mon, 1 Jul 2024 19:09:36 +0400 Subject: cmMakefile::FormatListFileStack: Exit early on empty stack trace And deindent the rest of the function. --- Source/cmMakefile.cxx | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 6bbfc7c..9952bd6 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -4261,20 +4261,23 @@ std::string cmMakefile::FormatListFileStack() const listFiles.emplace_back(snp.GetExecutionListFile()); } + if (listFiles.empty()) { + return {}; + } + std::reverse(listFiles.begin(), listFiles.end()); std::ostringstream tmp; size_t depth = listFiles.size(); - if (depth > 0) { - auto it = listFiles.end(); - do { - if (depth != listFiles.size()) { - tmp << "\n "; - } - --it; - tmp << '[' << depth << "]\t" << *it; - depth--; - } while (it != listFiles.begin()); - } + auto it = listFiles.end(); + do { + if (depth != listFiles.size()) { + tmp << "\n "; + } + --it; + tmp << '[' << depth << "]\t" << *it; + depth--; + } while (it != listFiles.begin()); + return tmp.str(); } -- cgit v0.12