code: private void switchToForward() {
          assert((checkDir < 0 && seq == rawSeq) || (checkDir == 0 && pos == limit));
          if(checkDir < 0) {
              // Turn around from backward checking.
              start = segmentStart = pos;
              if(pos == segmentLimit) {
                  limit = rawLimit;
                  checkDir = 1;  // Check forward.
              } else {  // pos < segmentLimit
                  checkDir = 0;  // Stay in FCD segment.
              }
          } else {
              // Reached the end of the FCD segment.
              if(seq == rawSeq) {
                  // The input text segment is FCD, extend it forward.
              } else {
                  // The input text segment needed to be normalized.
                  // Switch to checking forward from it.
                  seq = rawSeq;
                  pos = start = segmentStart = segmentLimit;
                  // Note: If this segment is at the end of the input text,
                  // then it might help to return false to indicate that, so that
                  // we do not have to re-check and normalize when we turn around and go backwards.
                  // However, that would complicate the call sites for an optimization of an unusual case.
              }
              limit = rawLimit;
              checkDir = 1;
          }
      }
docs: Switches to forward checking if possible.
  To be called when checkDir < 0 || (checkDir == 0 && pos == limit).
  Returns with checkDir > 0 || (checkDir == 0 && pos != limit).