oxc-project / oxc-project/backlog
`CloneIn` unnecessarily copies strings when cloning within same allocator
Nobody has claimed this yet.
- Dominant language
- No language data
- Stars
- 7
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
So Atom::clone_in copies the underlying string data and re-allocates it in new allocator.
This is the correct behavior when cloning from one allocator into another allocator - string data does need to be copied into the new allocator.
But when cloning within same allocator, this string copying is unnecessary. Could just do Atom::clone, which creates another reference to original underlying string data, with no data copy.
Not sure how to avoid this copying. Do we need a 2nd cloning trait for within-same-allocator cloning? And how would we enforce that the allocator provided to clone_in is the same allocator as the original? (or maybe we don't need to exactly - 'old_alloc: 'new_alloc would suffice to ensure that the string data in old allocator lives longer than the new Atom).
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading crates/oxc_span/src/atom.rs at lines 62-68 and 76-80, then trace how Atom::clone_in is used. Determine how same-allocator cloning can avoid copying while preserving correct cross-allocator behavior. Done means the unnecessary string allocation is avoided for same-allocator clones without changing cross-allocator semantics.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- performance
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100