Coverage Report

Created: 2025-09-08 06:20

/proc/self/cwd/cpp/htmlparser/document.cc
Line
Count
Source
1
#include "absl/flags/flag.h"
2
#include "cpp/htmlparser/document.h"
3
4
ABSL_FLAG(std::size_t, htmlparser_nodes_allocator_block_size,
5
          256 << 10 /* 256k */,
6
          "Allocator block size for html nodes.");
7
8
namespace htmlparser {
9
10
Document::Document() :
11
    node_allocator_(new Allocator<Node>(
12
        ::absl::GetFlag(FLAGS_htmlparser_nodes_allocator_block_size))),
13
12.5k
    root_node_(NewNode(NodeType::DOCUMENT_NODE)) {}
14
15
23.2M
Node* Document::NewNode(NodeType node_type, Atom atom) {
16
23.2M
  return node_allocator_->Construct(node_type, atom);
17
23.2M
}
18
19
6.00M
Node* Document::CloneNode(const Node* from) {
20
6.00M
  Node* clone = NewNode(from->Type());
21
6.00M
  clone->atom_ = from->atom_;
22
6.00M
  clone->data_ = from->data_;
23
6.00M
  clone->attributes_.reserve(from->Attributes().size());
24
6.00M
  std::copy(from->Attributes().begin(), from->Attributes().end(),
25
6.00M
            std::back_inserter(clone->attributes_));
26
6.00M
  return clone;
27
6.00M
}
28
29
}  // namespace htmlparser