-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Save regexp Pattern allocation on config name renaming #39444
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with your change but the order of arguments is not always the same and I think you copy/pasted things a bit too much.
I will adjust and force push.
if (!name.startsWith(oldPrefix)) { | ||
return name; | ||
} | ||
// don't use here String::replaceFirst because it uses regex |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah f**k. I thought replaceFirst
was like replace
and not using regexp :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I was surprised as well! Said that, you know that this change I'm pushing is a drop in the ocean which value is mostly on benchs as far as I can tell :/
And likely, the renaming will goes away in few releases too
fa48b97
to
73ff652
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I amended your commit to make sure the method was always called with the parameters in the correct order (relocate and fallback are symmetrical).
I also added a small test for your util as better to have it tested.
|
||
@Test | ||
public void testChangePrefix() { | ||
assertEquals("quarkus.new-prefix.configuration-property", StringUtil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice one!
private static final Function<String, String> RENAME_FUNCTION = new Function<String, String>() { | ||
@Override | ||
public String apply(String s) { | ||
return StringUtil.changePrefix(s, NEW_PREFIX, OLD_PREFIX); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gsmet My ide has been smarter than me and I fix it back (making it wrong) later on, uff :/ many thanks to have found it!
Thanks @gsmet for the review 🙏 |
Status for workflow
|
Thanks, good catch! |
This is addressing a small regression in case some old names are used, saving allocating (for each replacement) a whole new regexp
Pattern
and creating a reusable function which does it "right" if compared toString:.replaceFirst
.I've than removed the method reference lambda generation to match what we do elsewhere, but I have not a strong opinion here, considered that it mostly affect RSS footprint while the application doesn't do anything interesting (sadly a case still valuable in public benchmarks :/ ) - see #36204 (comment) for more info at
java/lang/invoke/LambdaForm.compileToBytecode
.In JDK 21 it's likely lambdas RSS footprint is reduced and who knows for later releases, so, as said, I've performed the change here, but I could have made the interceptors to implements
Function<String, String
and just passthis
to theirsuper
constructor too, not getting lambdas nor anonymous class loaded, at all.