-
Notifications
You must be signed in to change notification settings - Fork 8.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
optimize: remove repeated conditional tests (#3161) #3162
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #3162 +/- ##
=============================================
- Coverage 50.36% 50.27% -0.10%
- Complexity 3114 3117 +3
=============================================
Files 594 594
Lines 19625 19603 -22
Branches 2438 2393 -45
=============================================
- Hits 9885 9856 -29
+ Misses 8744 8731 -13
- Partials 996 1016 +20 |
@@ -156,6 +155,12 @@ | |||
} | |||
|
|||
public static Map<String, String> convert(Map<String, Object> param) { | |||
return param.keySet().stream().filter(key -> param.get(key) != null && param.get(key) != null).collect(Collectors.toMap(key -> key, key -> param.get(key).toString())); | |||
Map<String, String> covertMap = new HashMap<>(); |
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.
recommend move this method to io.seata.common.util.CollectionUtils and make a appropriate method name?
建议把这个方法移动到 io.seata.common.util.CollectionUtils,然后起个更合理的名字。
Map<String, String> covertMap = new HashMap<>(); | ||
param.forEach((key, value) -> { | ||
if (value != null) { | ||
covertMap.put(key, value.toString()); |
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.
recommend StringUtils.objectToString instead of value.toString()
建议StringUtils.objectToString替代value.toString
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.
LGTM.
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.
LGTM
Ⅰ. Describe what this PR did
1.remove Repeated conditional tests
2.keySet().stream()->map.foreach
Ⅱ. Does this pull request fix one issue?
fixes #3161
Ⅲ. Why don't you add test cases (unit test/integration test)?
Ⅳ. Describe how to verify it
Ⅴ. Special notes for reviews