Example #1
0
        internal static void SortNodesByPosition(
            ref XmlDiffNode firstNode,
            ref XmlDiffNode lastNode,
            ref XmlDiffNode firstPreviousSibbling)
        {
            var parent = firstNode._parent;

            if (firstPreviousSibbling == null && firstNode != parent._firstChildNode)
            {
                firstPreviousSibbling = parent._firstChildNode;
                while (firstPreviousSibbling._nextSibling != firstNode)
                {
                    firstPreviousSibbling = firstPreviousSibbling._nextSibling;
                }
            }
            var nextSibling = lastNode._nextSibling;

            lastNode._nextSibling = null;
            var count = 0;

            for (var xmlDiffNode = firstNode; xmlDiffNode != null; xmlDiffNode = xmlDiffNode._nextSibling)
            {
                ++count;
            }
            if (count >= 5)
            {
                XmlDiff.QuickSortNodes(ref firstNode, ref lastNode, count, firstPreviousSibbling, nextSibling);
            }
            else
            {
                XmlDiff.SlowSortNodes(ref firstNode, ref lastNode, firstPreviousSibbling, nextSibling);
            }
        }