private void ensureUpToDate() {
    if (!isUpToDate) {
      synchronized (this) {
        if (!isUpToDate) {
          recomputeIndex();
          isUpToDate = true;
        }
      }
    }
  }
private void ensureUpToDate()