String compare performance

Kagamin spam at here.lot
Sat Nov 27 15:10:33 PST 2010


You need only match 3-char strings?
Try this hack

bool cmp3c(string a, string etalon) pure
{
  if(a.length!=3)return false;
  return *cast(short*)a.ptr==*cast(short*)b.ptr && a[2]==b[2];
}


More information about the Digitalmars-d mailing list