Helper method for #precomputedInternal that doesn't test if the negation is cheaper.
(int totalCharacters, BitSet table, String description)
| 592 | */ |
| 593 | |
| 594 | @GwtIncompatible // java.util.BitSet |
| 595 | private static CharMatcher precomputedPositive(int totalCharacters, BitSet table, String description) { |
| 596 | switch (totalCharacters) { |
| 597 | case 0: |
| 598 | return none(); |
| 599 | case 1: |
| 600 | return is((char) table.nextSetBit(0)); |
| 601 | case 2: |
| 602 | char c1 = (char) table.nextSetBit(0); |
| 603 | char c2 = (char) table.nextSetBit(c1 + 1); |
| 604 | return isEither(c1, c2); |
| 605 | default: |
| 606 | return isSmall(totalCharacters, table.length()) |
| 607 | ? SmallCharMatcher.from(table, description) |
| 608 | : new BitSetMatcher(table, description); |
| 609 | } |
| 610 | } |
| 611 | |
| 612 | @GwtIncompatible // SmallCharMatcher |
| 613 | private static boolean isSmall(int totalCharacters, int tableLength) { |