-
Notifications
You must be signed in to change notification settings - Fork 38.3k
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 String.repeat() and pattern matching instanceof #27834
Use String.repeat() and pattern matching instanceof #27834
Conversation
34f0f99
to
f728ef7
Compare
@@ -360,38 +360,44 @@ protected DataAccessException createCustomException( | |||
// invoke constructor | |||
Constructor<?> exceptionConstructor; | |||
switch (constructorType) { |
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.
Guess that should be replaced with single return switch
with yield
s inside.
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.
done
} | ||
sb.append(s); | ||
s = sb.toString(); | ||
s = "0".repeat(this.paddingLength - len) + s; |
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.
This may be less efficient due to the need for allocation of a temporary String
.
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.
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.
Consider attaching benchmark's code
@AbstractCoderX, have you run a full local build?
Just curious, because the last time I checked.... we could not use switch expressions due to a limitation with Checkstyle (specifically Spring Java Format). |
As far as I can see, this has already been fixed, why does the codestyle check fail? |
The fix is in Line 323 in b24cbc5
|
In light of that, @AbstractCoderX feel free to move the "switch expression" changes to a separate PR so that we can merge in the other changes independent of that. |
6eb6f4a
to
727b14b
Compare
done |
@AbstractCoderX, are you planning on submitting a PR with the "switch expression" changes? |
I will do it this week |
Using various new features from Java 9-17 such as
String.repeat()
and pattern matching instanceof.