forked from Public-Mirror/Textractor
dont allow root modifiy
This commit is contained in:
parent
c596116a03
commit
69f5522492
@ -14,13 +14,12 @@ struct
|
|||||||
public:
|
public:
|
||||||
void Put(std::wstring original, std::wstring replacement)
|
void Put(std::wstring original, std::wstring replacement)
|
||||||
{
|
{
|
||||||
if (original.empty()) return;
|
|
||||||
Node* current = &root;
|
Node* current = &root;
|
||||||
for (auto c : original)
|
for (auto c : original)
|
||||||
if (Ignore(c));
|
if (Ignore(c));
|
||||||
else if (auto& next = current->next[c]) current = next.get();
|
else if (auto& next = current->next[c]) current = next.get();
|
||||||
else current = (next = std::make_unique<Node>()).get();
|
else current = (next = std::make_unique<Node>()).get();
|
||||||
current->value = replacement;
|
if (current != &root) current->value = replacement;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<int, std::wstring> Lookup(const std::wstring& text)
|
std::pair<int, std::wstring> Lookup(const std::wstring& text)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user