private NodeData AddAttribute(string localName, string prefix, string nameWPrefix)
{
NodeData newAttr = AddNode(_index + _attrCount + 1, _index + 1);
// set attribute name
newAttr.SetNamedNode(XmlNodeType.Attribute, localName, prefix, nameWPrefix);
// pre-check attribute for duplicate: hash by first local name char
int attrHash = 1 << (localName[0] & 0x1F);
if ((_attrHashtable & attrHash) == 0)
{
_attrHashtable |= attrHash;
}
else
{
// there are probably 2 attributes beginning with the same letter -> check all previous
// attributes
if (_attrDuplWalkCount < MaxAttrDuplWalkCount)
{
_attrDuplWalkCount++;
for (int i = _index + 1; i < _index + _attrCount + 1; i++)
{
NodeData attr = _nodes[i];
Debug.Assert(attr.type == XmlNodeType.Attribute);
if (Ref.Equal(attr.localName, newAttr.localName))
{
_attrDuplWalkCount = MaxAttrDuplWalkCount;
break;
}
}
}
}
_attrCount++;
return newAttr;
}