MCPcopy Create free account
hub / github.com/ElementsProject/elements / generateFirstLast

Function generateFirstLast

src/bench/nanobench.h:1485–1508  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1483}
1484
1485static bool generateFirstLast(Node const& n, size_t idx, size_t size, std::ostream& out) {
1486 ANKERL_NANOBENCH_LOG("n.type=" << static_cast<int>(n.type));
1487 bool matchFirst = n == "-first";
1488 bool matchLast = n == "-last";
1489 if (!matchFirst && !matchLast) {
1490 return false;
1491 }
1492
1493 bool doWrite = false;
1494 if (n.type == Node::Type::section) {
1495 doWrite = (matchFirst && idx == 0) || (matchLast && idx == size - 1);
1496 } else if (n.type == Node::Type::inverted_section) {
1497 doWrite = (matchFirst && idx != 0) || (matchLast && idx != size - 1);
1498 }
1499
1500 if (doWrite) {
1501 for (auto const& child : n.children) {
1502 if (child.type == Node::Type::content) {
1503 out.write(child.begin, std::distance(child.begin, child.end));
1504 }
1505 }
1506 }
1507 return true;
1508}
1509
1510static bool matchCmdArgs(std::string const& str, std::vector<std::string>& matchResult) {
1511 matchResult.clear();

Callers 2

generateResultFunction · 0.85

Calls 1

writeMethod · 0.45

Tested by

no test coverage detected