in EsentCollections/KeyRange.cs [434:478]
private static Key<T> UpperUnion(Key<T> a, Key<T> b)
{
Key<T> max;
if (null == a || null == b)
{
max = null;
}
else
{
int compare = CompareKeys(a, b);
if (0 == compare)
{
// Prefer the prefix/inclusive range
if (a.IsPrefix || b.IsPrefix)
{
max = a.IsPrefix ? a : b;
}
else
{
max = a.IsInclusive ? a : b;
}
}
else
{
if (a.IsPrefix && b.IsPrefix)
{
max = ComparePrefixes(a, b) > 0 ? a : b;
}
else if (a.IsPrefix)
{
max = CompareNonPrefixAndPrefix(b, a) > 0 ? b : a;
}
else if (b.IsPrefix)
{
max = CompareNonPrefixAndPrefix(a, b) > 0 ? a : b;
}
else
{
max = compare > 0 ? a : b;
}
}
}
return max;
}