Optimize *escape by testing a string before escaping