optimize two-way strstr and memmem bad character shift