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

Use static final Pattern to avoid regexp compilation each time replaceAll is called #5530

Merged
merged 2 commits into from Mar 4, 2024

Conversation

turbanoff
Copy link
Contributor

@turbanoff turbanoff commented Jan 30, 2024

Impact

  • Bug fix (non-breaking change which fixes expected existing functionality)
  • Enhancement/New feature (adds functionality without impacting existing logic)
  • Breaking change (fix or feature that would cause existing functionality to change)

Description

Improve performance of liquibase.Liquibase#getDatabaseChangeLog() a bit. I've noticed that pattern compilation takes some time in my profile.

Additional Context

String.replaceAll implementation:
https://github.com/openjdk/jdk/blob/fd8adf308357355bd33916ad80e2328c35434e5a/src/java.base/share/classes/java/lang/String.java#L3110

    public String replaceAll(String regex, String replacement) {
        return Pattern.compile(regex).matcher(this).replaceAll(replacement);
    }

image

Copy link
Contributor

@MalloD12 MalloD12 left a comment

Choose a reason for hiding this comment

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

Approved.

LGTM.

@MalloD12 MalloD12 changed the base branch from master to LB-752 February 19, 2024 20:11
@MalloD12 MalloD12 changed the base branch from LB-752 to master February 19, 2024 20:12
Copy link
Collaborator

@filipelautert filipelautert left a comment

Choose a reason for hiding this comment

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

Thanks for the enhancement @turbanoff !

@filipelautert filipelautert added this to the 1NEXT milestone Mar 4, 2024
@filipelautert filipelautert merged commit a57ac7d into liquibase:master Mar 4, 2024
31 of 33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

5 participants