# Use unstable sorts if deduplicating \(\#58751\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 78658778a28fe9bfac2de9caddcdad0eb4ea1cd7

Requested commit: 78658778a28fe9bfac2de9caddcdad0eb4ea1cd7

Commit: 78658778a28fe9bfac2de9caddcdad0eb4ea1cd7

Tree: 3cb6212f3e5ded2078c91d3dd957e113c967fdae

Author: Miguel Raz Guzmán Macedo

Committer: GitHub

## Message

```
Use unstable sorts if deduplicating (#58751)

# Impact

Recent Project picker, `find all references`, the sidebar's
`rebuild_contents` might get a slight speed boost.

# Reasoning

Unstable sort variants

https://doc.rust-lang.org/stable/std/primitive.slice.html#method.sort_unstable
are non-allocating but potentially destructive. Since we're
deduplicating elements anyways, use the unstable variant.

This call will use ipnsort


https://github.com/Voultapher/sort-research-rs/blob/main/writeup/unreasonable/text.md#various-generic-algorithms

I expect the speedups to be at least 30%, though it's highly input
dependent.

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 is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- N/A
```

## Parents

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

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