Skip to content

Commit d2b7828

Browse files
committed
csparser: make the code of guessKeyEvent() easier to follow
1 parent 247faea commit d2b7828

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/csparser.cc

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -360,21 +360,25 @@ bool KeyEventDigger::guessKeyEvent(Defect *def)
360360
return true;
361361
}
362362

363-
// use the last event as key event by default (unless black-listed)
363+
// use the last event as key event by default (unless deny-listed)
364364
for (int idx = evtCount - 1U; idx >= 0; --idx) {
365-
def->keyEventIdx = idx;
366365
const DefEvent &evt = evtList[idx];
367366
if (evt.event == "#")
368367
// never use comment as the key event
369368
continue;
370369

371370
const std::string &evtName = evt.event;
372-
if (!d->traceEvts.count(evtName) && !d->denyList.count(evtName))
373-
// never use trace or black-listed event as the key event
374-
break;
371+
if (d->traceEvts.count(evtName) || d->denyList.count(evtName))
372+
// never use trace or deny-listed event as the key event
373+
continue;
374+
375+
// matched
376+
def->keyEventIdx = idx;
377+
return true;
375378
}
376379

377-
return true;
380+
// no valid key event
381+
return false;
378382
}
379383

380384
void KeyEventDigger::initVerbosity(Defect *def)

0 commit comments

Comments
 (0)