# editor: Optimize selection overlap checking with binary search \(\#39773\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 47a66c938f9fe380c5c8c3eb5d80ea9990d8dcde

Requested commit: 47a66c938f9fe380c5c8c3eb5d80ea9990d8dcde

Commit: 47a66c938f9fe380c5c8c3eb5d80ea9990d8dcde

Tree: 6d06449a4f3801daa8ab3823da2722063b84030c

Author: Xiaobo Liu

Committer: GitHub

## Message

```
editor: Optimize selection overlap checking with binary search (#39773)

Replace O(n²) linear search with O(log n) binary search for checking
selection overlaps when finding next selection range. Pre-sort selection
ranges and use binary search to significantly improve performance when
working with many selections.

Release Notes:

- N/A

---------

Signed-off-by: Xiaobo Liu <cppcoffee@gmail.com>
```

## Parents

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

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