From 225caa2fe83505ba0002ea8adf336b9d58a41a6f Mon Sep 17 00:00:00 2001 From: Kurtis Rader Date: Sun, 30 Oct 2016 14:49:22 -0700 Subject: [PATCH] lint: Use early exit/continue --- src/parser.cpp | 67 +++++++++++++++++++++++++------------------------- 1 file changed, 34 insertions(+), 33 deletions(-) diff --git a/src/parser.cpp b/src/parser.cpp index 9406b3b9f..9e71ae062 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -270,45 +270,46 @@ static void print_profile(const std::vector &items, FILE *out) int my_time; me = items.at(pos); - if (!me->skipped) { - my_time = me->parse + me->exec; + if (me->skipped) { + continue; + } - for (i = pos + 1; i < items.size(); i++) { - prev = items.at(i); - if (prev->skipped) { - continue; - } - - if (prev->level <= me->level) { - break; - } - - if (prev->level > me->level + 1) { - continue; - } - - my_time -= prev->parse; - my_time -= prev->exec; + my_time = me->parse + me->exec; + for (i = pos + 1; i < items.size(); i++) { + prev = items.at(i); + if (prev->skipped) { + continue; + } + if (prev->level <= me->level) { + break; + } + if (prev->level > me->level + 1) { + continue; } - if (me->cmd.size() > 0) { - if (fwprintf(out, L"%d\t%d\t", my_time, me->parse + me->exec) < 0) { - wperror(L"fwprintf"); - return; - } + my_time -= prev->parse + prev->exec; + } - for (i = 0; i < me->level; i++) { - if (fwprintf(out, L"-") < 0) { - wperror(L"fwprintf"); - return; - } - } - if (fwprintf(out, L"> %ls\n", me->cmd.c_str()) < 0) { - wperror(L"fwprintf"); - return; - } + if (me->cmd.size() == 0) { + continue; + } + + if (fwprintf(out, L"%d\t%d\t", my_time, me->parse + me->exec) < 0) { + wperror(L"fwprintf"); + return; + } + + for (i = 0; i < me->level; i++) { + if (fwprintf(out, L"-") < 0) { + wperror(L"fwprintf"); + return; } } + + if (fwprintf(out, L"> %ls\n", me->cmd.c_str()) < 0) { + wperror(L"fwprintf"); + return; + } } }