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

Minor refactor of find_used_variables_* functions #5296

Merged
merged 2 commits into from
Apr 18, 2024

Conversation

kenodegard
Copy link
Contributor

@kenodegard kenodegard commented Apr 18, 2024

Description

This refactor adds a variant in text check before calling the more expensive re.search(PATTERN % variant, text). And while working on this went ahead and added a unittest!

Extracted from:

Extends #5283

Checklist - did you ...

  • Add a file to the news directory (using the template) for the next release's release notes?
  • Add / update necessary tests?
  • Add / update outdated documentation?

@conda-bot conda-bot added the cla-signed [bot] added once the contributor has signed the CLA label Apr 18, 2024
Copy link

codspeed-hq bot commented Apr 18, 2024

CodSpeed Performance Report

Merging #5296 will not alter performance

Comparing kenodegard:find_used_variables (5381d97) with main (28b51fb)

Summary

✅ 3 untouched benchmarks

@kenodegard kenodegard marked this pull request as ready for review April 18, 2024 03:06
@kenodegard kenodegard requested a review from a team as a code owner April 18, 2024 03:06
if (
variant in text # str in str is faster than re.search
and re.search(
rf"(^[^$]*?\$\{{?\s*{re.escape(variant)}\s*[\s|\}}])",
Copy link
Member

@jezdez jezdez Apr 18, 2024

Choose a reason for hiding this comment

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

Would it be useful to compile and cache this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not any more than re already does since we're formatting the pattern with the variant in each iteration

@kenodegard kenodegard merged commit f2c3f3b into conda:main Apr 18, 2024
30 checks passed
@kenodegard kenodegard deleted the find_used_variables branch April 18, 2024 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed [bot] added once the contributor has signed the CLA
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants