Skip to content

perf(lsp): avoid String cloning for fs.get_document#21040

Merged
graphite-app[bot] merged 1 commit intomainfrom
04-04-perf_lsp_avoid_string_cloning_for_fs.get_document_
Apr 4, 2026
Merged

perf(lsp): avoid String cloning for fs.get_document#21040
graphite-app[bot] merged 1 commit intomainfrom
04-04-perf_lsp_avoid_string_cloning_for_fs.get_document_

Conversation

@Sysix
Copy link
Copy Markdown
Member

@Sysix Sysix commented Apr 4, 2026

No description provided.

Copy link
Copy Markdown
Member Author

Sysix commented Apr 4, 2026


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent changes, fast-track this PR to the front of the merge queue

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions github-actions bot added A-editor Area - Editor and Language Server C-performance Category - Solution not expected to change functional behavior, only performance labels Apr 4, 2026
@Sysix Sysix requested a review from Copilot April 4, 2026 13:07
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR optimizes the language server’s in-memory document handling by switching document text storage from owned String cloning to shared Arc<str>, reducing allocations/copies when retrieving documents from the LSP file system.

Changes:

  • Change TextDocument.text from Option<String> to Option<Arc<str>>.
  • Store file contents in LSPFileSystem as Arc<str> and clone via Arc::clone in get_document.
  • Update affected tests to construct document text using Arc::from(...).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
crates/oxc_language_server/src/lib.rs Updates TextDocument API to use Option<Arc<str>> to enable cheap clones of document text.
crates/oxc_language_server/src/file_system.rs Stores file contents as Arc<str> and returns TextDocument with Arc clones instead of String clones.
crates/oxc_language_server/src/worker.rs Adjusts tests to match the new TextDocument::new(..., Option<Arc<str>>) signature.

@Sysix Sysix marked this pull request as ready for review April 4, 2026 13:12
@Sysix Sysix requested a review from camc314 as a code owner April 4, 2026 13:12
@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Apr 4, 2026
Copy link
Copy Markdown
Contributor

camc314 commented Apr 4, 2026

Merge activity

@graphite-app graphite-app bot force-pushed the 04-04-perf_lsp_avoid_string_cloning_for_fs.get_document_ branch from 4f147e7 to da6874a Compare April 4, 2026 15:36
@graphite-app graphite-app bot merged commit da6874a into main Apr 4, 2026
26 checks passed
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Apr 4, 2026
@graphite-app graphite-app bot deleted the 04-04-perf_lsp_avoid_string_cloning_for_fs.get_document_ branch April 4, 2026 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-editor Area - Editor and Language Server C-performance Category - Solution not expected to change functional behavior, only performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants