Using the xerces C++ source drop, ElementImpl.cpp Revision 1.9 2000/03/02 In ElementImpl::setAttribute(), a new AttrImpl object is created, populated and then inserted into ElementImpl::attributes using NamedNodeMapImpl::setNamedItem(). If an item with the same name already exists in the NamedNodeMap, it is replaced by the newly created item and deleted (pending reference counting).
Wouldn't it be more effective to check whether an attribute of this name exists first and, if so, repopulate it with the new data? Is there some compelling reason why the method was not implemented this way? The reason I ask is that I am working on a project in which we extend AttrImpl (among other classes). The current implementation of ElementImpl::setAttribute() causes problems since it replaces our objects which extend AttrImpl with AttrImpl base objects. This problem would disappear if an existence check was made before creating a new object. As a workaround, we override setAttribute() with our own implementation. Is there any chance that this method will be revisited in newer revisions? S.