Skip to content

Remove possible allocation of NodeList by eliminating IfElse. #808

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 22, 2025

Conversation

DanielRosenwasser
Copy link
Member

@DanielRosenwasser DanielRosenwasser commented Apr 18, 2025

Just a drive-by change. I'm not sure if the compiler is "smart enough" to get rid of the allocation, but it felt better to be more explicit anyway.

@Copilot Copilot AI review requested due to automatic review settings April 18, 2025 22:35
Copy link
Contributor

@Copilot 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 aims to optimize the allocation of the NodeList by eliminating the use of the IfElse construct.

  • Removed the conditional allocation using core.IfElse and replaced it with a pre-declared variable (tagsNodeList).
  • The change clarifies the code and potentially avoids unnecessary allocations.
Comments suppressed due to low confidence (1)

internal/parser/jsdoc.go:522

  • Ensure that passing nil as tagsNodeList to NewJSDoc is handled correctly in all execution paths to prevent potential nil dereference issues.
var tagsNodeList *ast.NodeList

Copy link
Member

@jakebailey jakebailey left a comment

Choose a reason for hiding this comment

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

The compiler is smart enough, but it would be an illegal transform because it would change the runtime behavior

@DanielRosenwasser DanielRosenwasser added this pull request to the merge queue Apr 22, 2025
Merged via the queue into main with commit c83b659 Apr 22, 2025
23 checks passed
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.

2 participants