# assistant_tools: Reduce allocations \(\#30776\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 8bec4cbecb38775cca43c465a59d70f7f0bcda17

Requested commit: 8bec4cbecb38775cca43c465a59d70f7f0bcda17

Commit: 8bec4cbecb38775cca43c465a59d70f7f0bcda17

Tree: 8ae36287d86bcd76f179f1f064300dbb4586da67

Author: tidely

Committer: GitHub

## Message

```
assistant_tools: Reduce allocations (#30776)

Another batch of allocation savings. Noteworthy ones are
`find_path_tool.rs` where one clone of *all* found matches was saved and
`web_tool_search.rs` where the tooltip no longer clones the entire url
on every hover.

I'd also like to propose using `std::borrow::Cow` a lot more around the
codebase instead of Strings. There are hundreds if not 1000+ clones that
can be saved pretty regularly simply by switching to Cow. ´Cow´'s are
likely not used because they aren't compatible with futures and because
it could cause lifetime bloat. However if we use `Cow<'static, str>`
(static lifetime) for when we need to pass them into futures, we could
save a TON of allocations for `&'static str`. Additionally I often see
structs being created using `String`'s just to be deserialized
afterwards, which only requires a reference.

Release Notes:

- N/A
```

## Parents

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

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