Skip to content

perf(BREAKING): parse_to_value - borrow object keys with Cow<'a, str> to avoid per-property allocation#80

Merged
dsherret merged 2 commits into
mainfrom
perf_object_keys_borrowed
Jul 7, 2026
Merged

perf(BREAKING): parse_to_value - borrow object keys with Cow<'a, str> to avoid per-property allocation#80
dsherret merged 2 commits into
mainfrom
perf_object_keys_borrowed

Conversation

@dsherret

@dsherret dsherret commented Jul 7, 2026

Copy link
Copy Markdown
Member

We already borrow the values, so it's more consistent (and faster) to also borrow the keys instead of doing an additional allocation.

Bench String keys Cow keys Speedup
package_json_value 23,361 ns 17,797 ns −23.8% (1.31×)
key_heavy_json_value* 11,125,850 ns 8,154,100 ns −26.7% (1.36×)
citm_catalog_json_large_value 29,799,430 ns 24,289,840 ns −18.5% (1.23×)
tsconfig_json_value 2,329 ns 2,182 ns −6.3% (1.07×)

This is unfortunately a breaking change, but I think it's more consistent and worth it.

@dsherret dsherret merged commit ab679c0 into main Jul 7, 2026
3 checks passed
@dsherret dsherret deleted the perf_object_keys_borrowed branch July 7, 2026 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant