improve performance of StringUtil.replace()

instead of #382