# editor: Ensure allocation reuse \(\#14577\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 09c497f744d1696a796cd55e1388e7895b8f20b8

Requested commit: 09c497f744d1696a796cd55e1388e7895b8f20b8

Commit: 09c497f744d1696a796cd55e1388e7895b8f20b8

Tree: c0646ab8883a0e24429c826b27a349c03e4f7f6a

Author: Piotr Osiewicz

Committer: GitHub

## Message

```
editor: Ensure allocation reuse (#14577)

In #14567 I claimed that the underlying allocation is reused. And it
was. At the time I've submitted a PR I was using `.filter_map(|x| x)`,
which got flagged by clippy as something that could be simplified to
`.flatten()` - that however broke the allocation reuse promise.

Thus, this PR goes back to using `filter_map` and additionally in debug
builds it performs checks for allocation reuse. With .flatten in place,
a bunch of unit test fail on that branch, so the checks do work.



Release Notes:

- N/A
```

## Parents

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

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