Skip to content
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

perf: use starlark string.removeprefix #544

Merged
merged 1 commit into from
Feb 8, 2024
Merged

perf: use starlark string.removeprefix #544

merged 1 commit into from
Feb 8, 2024

Conversation

jbedard
Copy link
Member

@jbedard jbedard commented Feb 8, 2024

I think this is even in 5.1 and ok for rules_ts? bazelbuild/bazel@50bb742


Type of change

  • Refactor (a code change that neither fixes a bug or adds a new feature)
  • Performance (a code change that improves performance)

Test plan

  • Covered by existing test cases

@jbedard jbedard requested a review from alexeagle February 8, 2024 09:49
Copy link
Member

@alexeagle alexeagle left a comment

Choose a reason for hiding this comment

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

This seems fine, are you starting from some profile of the analysis time that showed you this code was inefficient?

@jbedard
Copy link
Member Author

jbedard commented Feb 8, 2024

I know creating the large temp arrays has a side-effect. The temp array in this for loop is tiny, but the method is invoked frequently.

This change on it's own made no significant difference (when using ts_project + swc) but aspect-build/rules_swc#234, aspect-build/rules_swc@273eace and aspect-build/rules_swc@6bf6610 had very significant improvements so I'd prefer making this a pattern even if individual cases are not always significant.

@jbedard
Copy link
Member Author

jbedard commented Feb 8, 2024

Also repeating path.removeprefix("external/") 3x should make this functionally the same, but points out that we probably don't need it 3x?

@jbedard jbedard requested a review from alexeagle February 8, 2024 20:07
@jbedard jbedard merged commit 9c59dba into main Feb 8, 2024
48 checks passed
@jbedard jbedard deleted the string-rm-prefix branch February 8, 2024 22:22
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