# Speed up is_dirty and has_conflict \(\#11946\) · gitcafe/zed

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

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

Visibility: public

Requested revision: df3bd40c5614b9827f6dc0dc8794140b07b53116

Requested commit: df3bd40c5614b9827f6dc0dc8794140b07b53116

Commit: df3bd40c5614b9827f6dc0dc8794140b07b53116

Tree: 843fe7dc5b575e8ea30947a7be6449641a942753

Author: Max Brunsfeld

Committer: GitHub

## Message

```
Speed up is_dirty and has_conflict (#11946)

I noticed that scrolling the assistant panel was very slow in debug
mode, after running a completion. From profiling, I saw that it was due
to the buffer's `is_dirty` and `has_conflict` checks, which use
`edits_since` to check if there are any non-undone edits since the saved
version.

I optimized this in two ways:
* I introduced a specialized `has_edits_since` method on text buffers,
which allows us to more cheaply check if the buffer has been edited
since a given version, without some of the overhead involved in
computing what the edits actually are.
* In the case of `has_conflict`, we don't even need to call that method
in the case where the buffer doesn't have a file (is untitled, as is the
case in the assistant panel). Buffers without files cannot be in
conflict.

Release Notes:

- Improved performance of editing the assistant panel and untitled
buffers with many edits.
```

## Parents

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

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