# gpui: Add split and paint APIs on LineLayout \(\#60831\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/2936989f1b7a15aaf7131b0a3c17961d706fdbf5)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 2936989f1b7a15aaf7131b0a3c17961d706fdbf5

Requested commit: 2936989f1b7a15aaf7131b0a3c17961d706fdbf5

Commit: 2936989f1b7a15aaf7131b0a3c17961d706fdbf5

Tree: c0da2e4ffe1fac7cb12465231317e866ec4e8745

Author: Agus Zubiaga

Committer: GitHub

## Message

```
gpui: Add split and paint APIs on LineLayout (#60831)

`ShapedLine` is nearly 3KB by value because it inlines a
`SmallVec<[DecorationRun; 32]>`. A consumer that builds wrapped lines
out of many small uniformly styled fragments only needs the shaped
glyphs plus a single decoration run it can track itself, but it ends up
moving and reallocating that mostly dead capacity constantly because
splitting and painting are only reachable through `ShapedLine`.

This moves the glyph-partitioning half of `ShapedLine::split_at` down to
a new `LineLayout::split_at`, and adds
`LineLayout::paint`/`paint_background` methods that take explicit
decoration runs. Together with the already-public `layout_line`, callers
can now hold a bare `Arc<LineLayout>` and their own decorations.
`ShapedLine::split_at` delegates to the new method and behaves the same.

## Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)
- [ ] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

---

Release Notes:

- N/A
```

## Parents

- [314e0902ca079a01659b63a25785131774d66633](https://git.cafe/gitcafe/zed/commit/314e0902ca079a01659b63a25785131774d66633?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/2936989f1b7a15aaf7131b0a3c17961d706fdbf5?format=markdown)
