-
-
Notifications
You must be signed in to change notification settings - Fork 1.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
Remove Unused comment in Logger #869
base: master
Are you sure you want to change the base?
Remove Unused comment in Logger #869
Conversation
68f3b5d
to
9015b2e
Compare
} | ||
for (final Logger child : childrenList) { | ||
if (childName.equals(child.getName())) { | ||
return child; | ||
} |
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.
Use for-each to optimize
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 like this optimization, but I propose taking it further and ensuring that childrenList
is always an instance of CopyOnWriteArrayList
transient private List<Logger> childrenList;
↓↓↓
transient private final List<Logger> childrenList = new CopyOnWriteArrayList<>();
or, with modifiers sorted
private final transient List<Logger> childrenList = new CopyOnWriteArrayList<>();
Then all the null checks could be removed and there would be not even a remote possibility that childrenList
's iterator could throw ConcurrentModificationException
.
It may even fix some subtle visibility issues. There are some unsynchronized null checks against childrenList
that may read a stale value. e.g.
Logger createChildByLastNamePart(final String lastPart) {
…
if (childrenList == null) {
^^^^^^^^^^^^^^^^^^^^
childrenList = new CopyOnWriteArrayList<Logger>();
}
…
}
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.
Very good suggestion, I can't agree more, updated.
for (int i = 0; i < len; i++) { | ||
Logger child = (Logger) childrenList.get(i); | ||
for (Logger childLogger : childrenList) { | ||
// tell child to handle parent levelInt change | ||
child.handleParentLevelChange(effectiveLevelInt); | ||
childLogger.handleParentLevelChange(effectiveLevelInt); |
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.
Use for-each to optimize.
for (Logger childLogger : childrenList) { | ||
childLogger.handleParentLevelChange(newParentLevelInt); |
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.
Use for-each to optimize
/** | ||
* The default size of child list arrays. The JDK 1.5 default is 10. We use a | ||
* smaller value to save a little space. | ||
*/ |
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.
Remove the unused comment.
* | ||
* |
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'd be inclined to take out unnecessary, unrelated changes to make it easier on the maintainers
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.
Sorry, this is caused by my IDEA setting, now I revert this.
4b8167c
to
03cd226
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.
Your PR title is "Remove Unused comment in LoggerContext", but the comment you removed is in Logger
. In LoggerContext
you removed redundant casting and type information and unused imports. These codebase modernization activities could be done en masse using tools, but don't seem to be a project priority. I'd be inclined to separate or discard inconsequential changes. In Logger
you do many things other than remove a comment. I suggest focusing your PR and not neglecting the PR title and description. Maintainers appreciate an accurate title and overview.
Thanks suggestions, this help me not only on this PR but in the future work. So I need to separate this PR and change the title to /**
* The default size of child list arrays. The JDK 1.5 default is 10. We use a
* smaller value to save a little space.
*/ |
No guarantee to get attention of maintainers, but that sounds like a focused PR to me. I encourage you to read the contribution guidelines. Wish you luck. |
Signed-off-by: Wenjun Ruan <[email protected]>
03cd226
to
7419ed9
Compare
No description provided.