Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove IntervalCache + rework BTree Collection adapters and BTreeMetric #119

Merged
merged 51 commits into from
Mar 7, 2024

Conversation

davidbalbert
Copy link
Owner

  • Instead caching text layout info (Line structs) in IntervalCache, which was slow and had to be updated every frame, cache them in CALayers.
    • There's missing piece, which is that some caret navigation is layout dependent (move up, move down, etc.), and if the caret is off the screen, we'd want to cache that layout info too. This isn't a big deal for a single caret, but becomes more important for multiple selections. Tracking in Cache layout information for selection navigation #118.
  • Fix a bug where putting a caret at the beginning of the last line and pressing Shift-Right Arrow, would panic.
  • Rewrite Rope.LineView to no longer have a separate endIndex after the Rope's endIndex (omg what a relief).
  • Only validate BTree indices with preconditions at the boundary where external code passes in an Index into a Rope/BTree API. Use debug assertions at BTree internal function boundaries. This improves performance by validating less.
  • Remove BTreeMetric.type and allow each metric to be measured on both leading and trailing boundaries.
  • Rework the BTree Collection adapter APIs to use this functionality, and extended them to take a Range argument that lets you use them for slice types (Subrope, Rope.UnicodeScalarView, etc.).
  • Made Spans a Collection and added SpansSlice. The latter improves AttributedRope performance.
  • Add a count(in range:) method to the BTree Collection adapters. This relies on the leading/trailing boundary changes above, and was necessary for Spans' Collection conformance as well as SpansSlice.
  • Made AttributedRope.Runs a collection and removed some awkward APIs for reading AttributedRope.Attributes for a specific index.
  • Rearchitect Heights to use the new support for boundaries in BTreeMetric, which cleaned things up quite a bit.

We know startIndex and endIndex are valid, and the BTreeNode.index* functions validate for us.
This fixes a bug in height calculation due to a semantic change in BTree Collection helpers – specifically, in the Collection helpers, startIndex and endIndex are always boundaries.
Also:

- Introduce SpansSlice
- Fix moving to next index on leading boundaries
@davidbalbert davidbalbert merged commit d11ea68 into main Mar 7, 2024
@davidbalbert davidbalbert deleted the remove-line-cache branch March 7, 2024 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant