From 3af93a39d7dddadc13fba978da113aa847509ee5 Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Fri, 20 Oct 2017 21:57:14 -0700 Subject: Clarify a note about compact hash behavior during move After move some nodes in the hash table can have keys that point to other; this makes the table somewhat larger but this does not impact correctness. The reason is that for us to access a key in the hash table, there should be a compact_pointer/string object with the state indicating that it is stored in a hash table, and with the address matching the key. For this to happen, we had to have put this object into this state which would mean that we'd overwrite the hash entry with the new, correct value. When nodes/pages are being removed, we do not clean up keys from the hash table - it's safe for the same reason, and thus move doesn't introduce additional contracts here. --- src/pugixml.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/pugixml.cpp b/src/pugixml.cpp index 2371813..554d8df 100644 --- a/src/pugixml.cpp +++ b/src/pugixml.cpp @@ -6963,8 +6963,7 @@ namespace pugi xml_node_struct* other_first_child = other->first_child; #ifdef PUGIXML_COMPACT - // move compact hash - // TODO: the hash still has pointers to other, do we need to clear them out? + // move compact hash; note that the hash table can have pointers to other but they will be "inactive", similarly to nodes removed with remove_child doc->hash = other->hash; doc->_hash = &doc->hash; -- cgit v1.2.3