StringExp.compare

Compare two StringExp by length, then value

The comparison is not the usual C-style comparison as seen with strcmp or memcmp, but instead first compare based on the length. This allows both faster lookup and sorting when comparing sparse data.

This ordering scheme is relied on by the string-switching feature. Code in Druntime's core.internal.switch_ relies on this ordering when doing a binary search among case statements.

Both StringExp should be of the same encoding.

class StringExp
const nothrow pure @nogc
int
compare
()

Parameters

se2 StringExp

String expression to compare this to

Return Value

Type: int

0 when this is equal to se2, a value greater than 0 if this should be considered greater than se2, and a value less than 0 if this is lesser than se2.

Suggestion Box / Bug Report