-
Notifications
You must be signed in to change notification settings - Fork 656
Improvements #1057
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
base: master
Are you sure you want to change the base?
Improvements #1057
Conversation
String tag = settings.getString(sessionID, logonTagSetting); | ||
String[] split = tag.split("=", 2); | ||
StringField stringField = new StringField(Integer.valueOf(split[0]), split[1]); | ||
StringField stringField = new StringField(Integer.parseInt(split[0]), split[1]); |
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.
removed redundant auto-boxing
eventFileName = prefix + "event.log"; | ||
|
||
File directory = new File(messagesFileName).getParentFile(); | ||
if (!directory.exists()) { |
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.
redundant check as directory.mkdir()
has exists check inbuilt
} | ||
|
||
public class RedundantHandlerException extends RuntimeException { | ||
public static class RedundantHandlerException extends RuntimeException { |
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.
non-static inner class will unnecessarily carry a reference to the outer class
} | ||
|
||
private class Invoker { | ||
private static class Invoker { |
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.
non-static inner class will unnecessarily carry a reference to the outer class
try { | ||
DatabaseEntry sequenceKey = new DatabaseEntry(); | ||
EntryBinding sequenceBinding = TupleBinding.getPrimitiveBinding(Integer.class); | ||
EntryBinding<Integer> sequenceBinding = TupleBinding.getPrimitiveBinding(Integer.class); |
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.
Making variable type safe at source instead of doing type-casting everytime it is used
for (int index = 0; ; index++) { | ||
try { | ||
final String protocolKey = Initiator.SETTING_SOCKET_CONNECT_PROTOCOL | ||
+ (index == 0 ? "" : Integer.toString(index)); |
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.
every Integer.toString(index)
will create a new object.
reducing innecessary garbage creation
if (sniHostName != null) { | ||
SSLParameters sslParameters = sslEngine.getSSLParameters(); | ||
sslParameters.setServerNames(Arrays.asList(new SNIHostName(sniHostName))); | ||
sslParameters.setServerNames(Collections.singletonList(new SNIHostName(sniHostName))); |
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.
Arrays.asList(new SNIHostName(sniHostName))
- creates 2 objects
- new SNIHostName(sniHostName)
- Array object when we do Arrays.asList
Collections.singletonList(new SNIHostName(sniHostName))
- creates 1 object of SNIHostName and wraps it in the Collection obeject
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.
Will check the other points, but this code is called typically only once. Good point, though.
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.
Please roll back the import
changes.
done. out of curiosity - is the intention that we only import the classes that are required and not the whole package because importing is a compile time task and I don't think it has any latency implications. |
The intention is simply that one uses IntelliJ, another uses Eclipse, a third Netbeans and either has its own taste of how imports should be organized (unless you configure it the same for all IDEs). |
Got it. Thanks I've reverted the import changes. I didn't get much time after this initial one where my changes were around non-critical execution path which were called once maybe twice in the life cycle |
Changes :