Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Sysix
Copy link
Member

@Sysix Sysix commented Nov 10, 2025

This PR optimizes performance by passing file content as a reference (&String) instead of by value (String) throughout the language server's diagnostic and formatting functions. This avoids unnecessary string clones when passing file content through the call chain.

@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 Nov 10, 2025
Copy link
Member Author

Sysix commented Nov 10, 2025


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 hot fixes, skip the queue and merge this PR next

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.

@Sysix Sysix changed the title perf(language_servr): pass file content as a referenced String perf(language_server): pass file content as a referenced String Nov 10, 2025
@Sysix Sysix requested a review from Copilot November 10, 2025 21:57
Copilot finished reviewing on behalf of Sysix November 10, 2025 21:58
Copy link
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 performance by passing file content as a reference (&String) instead of by value (String) throughout the language server's diagnostic and formatting functions. This avoids unnecessary string clones when passing file content through the call chain.

Key changes:

  • Updated trait method signatures in the Tool trait to accept Option<&String> instead of Option<String>
  • Modified all implementations and call sites to use referenced strings
  • Added temporary variable handling in the formatter to manage lifetime requirements

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
crates/oxc_language_server/src/worker.rs Updated worker methods to pass content as references using .as_ref()
crates/oxc_language_server/src/tool.rs Changed trait method signatures to accept Option<&String> instead of Option<String>
crates/oxc_language_server/src/linter/server_linter.rs Updated linter implementations to accept referenced strings
crates/oxc_language_server/src/linter/isolated_lint_handler.rs Modified to handle referenced strings with temporary lifetime management
crates/oxc_language_server/src/formatter/server_formatter.rs Added temporary variable to manage string lifetimes when reading from filesystem

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Sysix Sysix force-pushed the 11-10-perf_language_servr_pass_file_content_as_a_referenced_string_ branch from 32d2937 to c486039 Compare November 10, 2025 22:01
@Sysix Sysix marked this pull request as ready for review November 10, 2025 22:02
@Sysix Sysix requested a review from camc314 as a code owner November 10, 2025 22:02
Copy link
Contributor

@camc314 camc314 left a comment

Choose a reason for hiding this comment

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

why &String vs &str

@Sysix Sysix force-pushed the 11-10-perf_language_servr_pass_file_content_as_a_referenced_string_ branch from c486039 to de9fe05 Compare November 11, 2025 17:27
@Sysix
Copy link
Member Author

Sysix commented Nov 11, 2025

@camc314 updated the code to use &str, needed to change the Backend a bit for it :)

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