/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 | 11.5k | root_node_(NewNode(NodeType::DOCUMENT_NODE)) {} |
14 | | |
15 | 24.3M | Node* Document::NewNode(NodeType node_type, Atom atom) { |
16 | 24.3M | return node_allocator_->Construct(node_type, atom); |
17 | 24.3M | } |
18 | | |
19 | 7.41M | Node* Document::CloneNode(const Node* from) { |
20 | 7.41M | Node* clone = NewNode(from->Type()); |
21 | 7.41M | clone->atom_ = from->atom_; |
22 | 7.41M | clone->data_ = from->data_; |
23 | 7.41M | clone->attributes_.reserve(from->Attributes().size()); |
24 | 7.41M | std::copy(from->Attributes().begin(), from->Attributes().end(), |
25 | 7.41M | std::back_inserter(clone->attributes_)); |
26 | 7.41M | return clone; |
27 | 7.41M | } |
28 | | |
29 | | } // namespace htmlparser |