| 128 | } |
| 129 | |
| 130 | Status TrieBuilder::SplitNode(fast_index_type node_index, fast_index_type split_at) { |
| 131 | Trie::Node* node = &trie_.nodes_[node_index]; |
| 132 | |
| 133 | DCHECK_LT(split_at, node->substring_length()); |
| 134 | |
| 135 | // Before: |
| 136 | // {node} -> [...] |
| 137 | // After: |
| 138 | // {node} -> [c] -> {out_node} -> [...] |
| 139 | auto child_node = Trie::Node{node->found_index_, node->child_lookup_, |
| 140 | node->substring_.substr(split_at + 1)}; |
| 141 | auto ch = node->substring_[split_at]; |
| 142 | node->child_lookup_ = -1; |
| 143 | node->found_index_ = -1; |
| 144 | node->substring_ = node->substring_.substr(0, split_at); |
| 145 | RETURN_NOT_OK(AppendChildNode(node, ch, std::move(child_node))); |
| 146 | |
| 147 | return Status::OK(); |
| 148 | } |
| 149 | |
| 150 | Status TrieBuilder::Append(std::string_view s, bool allow_duplicate) { |
| 151 | // Find or create node for string |
nothing calls this directly
no test coverage detected