static int countOccurrences_optimizedForZero(S s, S x) { // The first line doesn't seem faster (and why should it) //ret !contains(s, x) ? 0 : countOccurrences(s, x); ret countOccurrences(s, x); }