@@ -323,11 +323,10 @@ static void operator<<(json::OStream &W,
323
323
for (const auto &Loc : Point->Locs ) {
324
324
if (Loc.FileName != FileName || Loc.FunctionName != FunctionName)
325
325
continue ;
326
- if (WrittenIds.find (Point->Id ) != WrittenIds. end () )
326
+ if (! WrittenIds.insert (Point->Id ). second )
327
327
continue ;
328
328
329
329
// Output <point_id> : "<line>:<col>".
330
- WrittenIds.insert (Point->Id );
331
330
W.attribute (Point->Id ,
332
331
(utostr (Loc.Line ) + " :" + utostr (Loc.Column )));
333
332
}
@@ -418,17 +417,15 @@ SymbolizedCoverage::read(const std::string &InputFile) {
418
417
auto LineStr = Loc.substr (0 , ColonPos);
419
418
auto ColStr = Loc.substr (ColonPos + 1 , Loc.size ());
420
419
421
- if (Points.find (PointId) == Points.end ())
422
- Points.insert (std::make_pair (PointId, CoveragePoint (PointId)));
423
-
424
420
DILineInfo LineInfo;
425
421
LineInfo.FileName = Filename;
426
422
LineInfo.FunctionName = FunctionName;
427
423
char *End;
428
424
LineInfo.Line = std::strtoul (LineStr.c_str (), &End, 10 );
429
425
LineInfo.Column = std::strtoul (ColStr.c_str (), &End, 10 );
430
426
431
- CoveragePoint *CoveragePoint = &Points.find (PointId)->second ;
427
+ CoveragePoint *CoveragePoint =
428
+ &Points.try_emplace (PointId, PointId).first ->second ;
432
429
CoveragePoint->Locs .push_back (LineInfo);
433
430
}
434
431
}
@@ -576,10 +573,8 @@ getCoveragePoints(const std::string &ObjectFile,
576
573
FrameInfo.FileName = normalizeFilename (FrameInfo.FileName );
577
574
if (Ig.isIgnorelisted (FrameInfo))
578
575
continue ;
579
- if (Infos.find (FrameInfo) == Infos.end ()) {
580
- Infos.insert (FrameInfo);
576
+ if (Infos.insert (FrameInfo).second )
581
577
Point.Locs .push_back (FrameInfo);
582
- }
583
578
}
584
579
585
580
Result.push_back (Point);
0 commit comments