Skip to content

Optimize span usage to avoid unnecessary cloning #86

@coderabbitai

Description

@coderabbitai

Issue Description

Cloning the span for src.get may be unnecessary.

Consider using a reference or passing Span by value if it implements Copy, as this may improve performance and code clarity.

Location

src/parser/cst_builder/tree.rs:117

Code Context

fn push_token(builder: &mut GreenNodeBuilder, kind: SyntaxKind, span: Span, src: &str) {
    let text = src.get(span.clone()).map_or_else(
        || {

Suggested Improvement

Consider whether span.clone() is necessary or if span can be used directly, especially if Span implements Copy.

References

Metadata

Metadata

Assignees

Labels

lowLow criticality issue

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions