[xml] docs and dicts in xmlSetTreeDoc()


I've just fixed a long-standing problem in lxml, now I'm wondering if it isn't
actually a problem in libxml2. The function xmlSetTreeDoc() in tree.c is
called to update the xmlDoc* pointers of each node in a subtree when it gets
appended to a new parent in a different document. The question is: should this
function also re-assign the "name" pointers of the nodes if both documents use
a dict and the dictionary of the target document is different from the
dictionary of the source tree?

The decision is easy to take (compare the dict pointers of both documents) and
the code to re-assign the name is simple: call xmlDictLookup() and re-assign
the name of the node to the result. In addition, a call to
xmlDictOwns(old_dict, old_name) might be necessary to see if the old name must
be freed.

Would this be considered worth changing? Or are there any reasons not to do
this? There obviously is a performance impact, but I consider it the correct
thing to do if both documents are meant to be independent afterwards.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]