startswith/endswith optimizations