private @NotNull UpdatedRanges getUpdatedMarkers(@NotNull FrozenDocument frozen, @NotNull List<? extends DocumentEvent> events) {
    int eventCount = events.size();
    assert eventCount > 0;

    UpdatedRanges cache = myUpdatedRanges;
    if (cache != null && cache.myEventCount == eventCount) return cache;

    UpdatedRanges answer;
    if (cache != null && cache.myEventCount < eventCount) {
      // apply only the new events
      answer = applyEvents(events.subList(cache.myEventCount, eventCount), cache);
    }
    else {
      List<SelfElementInfo> infos = myPointers.getSortedInfos();
      ManualRangeMarker[] markers = createMarkers(infos);
      answer = applyEvents(events, new UpdatedRanges(0, frozen, infos, markers));
    }

    myUpdatedRanges = answer;
    return answer;
  }
private @NotNull UpdatedRanges getUpdatedMarkers(@NotNull FrozenDocument frozen, @NotNull List<? extends DocumentEvent> events)