Optimised string comparison