-
-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
优化Properties#stringPropertyNames处理,jdk9以下版本此方法cpu消耗相对过高. #1072
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1072 +/- ##
=============================================
+ Coverage 31.21% 48.65% +17.43%
- Complexity 111 1680 +1569
=============================================
Files 39 365 +326
Lines 977 10174 +9197
Branches 122 1030 +908
=============================================
+ Hits 305 4950 +4645
- Misses 628 4860 +4232
- Partials 44 364 +320
Continue to review full report at Codecov.
|
Coverage increased (+0.008%) to 52.221% when pulling 962e4ef8c0576ba40f83a1b1feeea832299ac4d8 on wuwen5:properties#preform into dc65300 on ctripcorp:master. |
3204d46
to
72067bf
Compare
import java.util.Objects; | ||
import java.util.Properties; | ||
import java.util.Set; | ||
import java.util.*; |
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.
这里似乎是IDE自动更新为*了,建议只import实际需要的package
|
||
private Set<String> stringPropertyNames(Properties properties) { | ||
//jdk9以下版本Properties#enumerateStringProperties方法存在性能问题,keys() + get(k) 重复迭代, jdk9之后改为entrySet遍历. | ||
Map<String, String> h = 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.
这段代码虽然是从jdk9复制过来的,还是建议加一段UT来测试,以防后续被其它人改错逻辑。
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.
ok已增加.
0c5c69b
to
4e25576
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.
感谢!
ut的assertEquals应该可以利用现有的stringPropertyNames实现来比较。
另外,是否能再增加一个properties为空的test case?
|
||
Set<String> propertyNames = defaultConfig.getPropertyNames(); | ||
|
||
assertEquals(10, propertyNames.size()); |
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.
assertEquals(someProperties.stringPropertyNames(), propertyNames) ?
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.
Thanks!
参考相关修改, http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/01a8615439f0#l2.164