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]; }