optimisation: check the first character before calling memcmp