# Optimize JSON merging by removing redundant key clones in serde_json operations \(\#25866\) · gitcafe/zed

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

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

Visibility: public

Requested revision: e65471c7a1a1a7b8195f40447549158953883985

Requested commit: e65471c7a1a1a7b8195f40447549158953883985

Commit: e65471c7a1a1a7b8195f40447549158953883985

Tree: 4473ce7cc8bcc3fdf604ed2dc27086b60fcab54f

Author: greathongtu

Committer: GitHub

## Message

```
Optimize JSON merging by removing redundant key clones in serde_json operations (#25866)

Hi Zed team! 👋
As a fan of Zed Editor who's excited to contribute, I noticed a small
optimization opportunity in the JSON merging utilities.

<b>Changes:</b>
Removed redundant key.clone() calls in insert() operations within 2
functions:
1. merge_json_value_into
2. merge_non_null_json_value_into

<b>Why:</b>
Since we're already moving ownership of `source_object` 's contents and
key is no longer used further, we could directly pass `key` to `insert`
without cloning.
Eliminates redundant allocations, improving performance slightly for
JSON-heavy operations.

<b>Testing:</b>
I have tested this locally and all existing tests passed. The change
preserves behavior while removing redundancy.

Love using Zed and happy to contribute! Let me know if any adjustments
are needed!

Release Notes:

- N/A
```

## Parents

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

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