Skip to content

Commit 5a10a5d

Browse files
committed
parser-json-cov: introduce covDecodeEvt() helper
... to make the code easier to maintain. No change in behavior intended. Related: #222
1 parent faa637d commit 5a10a5d

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

Diff for: src/lib/parser-json-cov.cc

+15-9
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,26 @@ CovTreeDecoder::CovTreeDecoder(InStream &input):
4141

4242
CovTreeDecoder::~CovTreeDecoder() = default;
4343

44+
/// decode single event
45+
static DefEvent covDecodeEvt(const pt::ptree &evtNode)
46+
{
47+
DefEvent evt;
48+
49+
evt.fileName = valueOf<std::string>(evtNode, "filePathname");
50+
evt.line = valueOf<int> (evtNode, "lineNumber");
51+
evt.column = valueOf<int> (evtNode, "columnNumber");
52+
evt.event = valueOf<std::string>(evtNode, "eventTag");
53+
evt.msg = valueOf<std::string>(evtNode, "eventDescription");
54+
55+
return evt;
56+
}
57+
4458
void CovTreeDecoder::Private::readEvents(Defect *def)
4559
{
4660
// go through the list of events
4761
const pt::ptree &evtList = this->pSrc->get_child("events");
4862
for (const auto &item : evtList) {
4963
const pt::ptree &evtNode = item.second;
50-
51-
// decode single event
52-
DefEvent evt;
53-
evt.fileName = valueOf<std::string>(evtNode, "filePathname");
54-
evt.line = valueOf<int> (evtNode, "lineNumber");
55-
evt.column = valueOf<int> (evtNode, "columnNumber");
56-
evt.event = valueOf<std::string>(evtNode, "eventTag");
57-
evt.msg = valueOf<std::string>(evtNode, "eventDescription");
58-
5964
if (evtNode.get<bool>("main")) {
6065
// this is a key event
6166

@@ -70,6 +75,7 @@ void CovTreeDecoder::Private::readEvents(Defect *def)
7075
}
7176

7277
// push the event to the list of events
78+
DefEvent evt = covDecodeEvt(evtNode);
7379
def->events.push_back(std::move(evt));
7480
}
7581
}

0 commit comments

Comments
 (0)