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.
This commit is contained in:
Arseny Kapoulkine 2017-10-20 21:57:14 -07:00
parent b0fc587a7f
commit 3af93a39d7

View File

@ -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;