mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-python
synced 2026-01-15 09:53:32 +01:00
String Tree: Fix order of overwrites
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
126ecbb411
commit
64ce94b142
1 changed files with 5 additions and 0 deletions
|
|
@ -104,8 +104,13 @@ class StringTree: # export
|
||||||
if l > 1:
|
if l > 1:
|
||||||
assert len(rest) > 0
|
assert len(rest) > 0
|
||||||
return self.children[nibble].__set(rest, content=content)
|
return self.children[nibble].__set(rest, content=content)
|
||||||
|
# last component, a.k.a. leaf
|
||||||
if content is not None:
|
if content is not None:
|
||||||
gc = content if isinstance(content, StringTree) else StringTree('', content=content)
|
gc = content if isinstance(content, StringTree) else StringTree('', content=content)
|
||||||
|
# Make sure no existing grand child is updated. It would reside too
|
||||||
|
# far up in the grand child OrderedDict, we need it last
|
||||||
|
if gc.content in self.children[nibble].children:
|
||||||
|
del self.children[nibble].children[gc.content]
|
||||||
self.children[nibble].children[gc.content] = gc
|
self.children[nibble].children[gc.content] = gc
|
||||||
return self.children[nibble]
|
return self.children[nibble]
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue