MCPcopy Create free account
hub / github.com/BYVoid/OpenCC / AddEntry

Method AddEntry

src/PrefixMatch.cpp:196–218  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

194
195private:
196 void AddEntry(const std::string& key, const std::string& value) {
197 Node* node = &root;
198 for (const char* pstr = key.c_str(); *pstr != '\0';) {
199 const size_t remainingLength = key.c_str() + key.length() - pstr;
200 const size_t charLength = Utf8CharLength(pstr, remainingLength);
201 if (charLength == 0) {
202 break;
203 }
204 std::unique_ptr<Node>& child =
205 node->children[Utf8CharKey(pstr, charLength)];
206 if (child == nullptr) {
207 child.reset(new Node);
208 }
209 node = child.get();
210 pstr += charLength;
211 }
212 if (!node->candidate.hasValue) {
213 node->candidate.hasValue = true;
214 node->candidate.keyLength = key.length();
215 node->candidate.key = key;
216 node->candidate.value = value;
217 }
218 }
219
220 Node root;
221};

Callers

nothing calls this directly

Calls 5

Utf8CharLengthFunction · 0.85
Utf8CharKeyFunction · 0.85
lengthMethod · 0.45
resetMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected