MCPcopy Create free account
hub / github.com/Kitware/CMake / splitCostLine

Function splitCostLine

Source/CTest/cmCTestMultiProcessHandler.cxx:63–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61};
62
63cm::optional<CostEntry> splitCostLine(cm::string_view line)
64{
65 std::string part;
66 cm::string_view::size_type pos1 = line.size();
67 cm::string_view::size_type pos2 = line.find_last_of(' ', pos1);
68 auto findNext = [line, &part, &pos1, &pos2]() -> bool {
69 if (pos2 != cm::string_view::npos) {
70 cm::string_view sub = line.substr(pos2 + 1, pos1 - pos2 - 1);
71 part.assign(sub.begin(), sub.end());
72 pos1 = pos2;
73 if (pos1 > 0) {
74 pos2 = line.find_last_of(' ', pos1 - 1);
75 }
76 return true;
77 }
78 return false;
79 };
80
81 // parse the cost
82 if (!findNext()) {
83 return cm::nullopt;
84 }
85 float cost = static_cast<float>(atof(part.c_str()));
86
87 // parse the previous runs
88 if (!findNext()) {
89 return cm::nullopt;
90 }
91 int prev = atoi(part.c_str());
92
93 // from start to the last found space is the name
94 return CostEntry{ line.substr(0, pos1), prev, cost };
95}
96
97}
98

Callers 2

UpdateCostDataMethod · 0.85
ReadCostDataMethod · 0.85

Calls 7

find_last_ofMethod · 0.80
assignMethod · 0.80
c_strMethod · 0.80
sizeMethod · 0.45
substrMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…