Replace emptiness checks with isEmpty()#7468
Conversation
|
Just in case the @State(Scope.Benchmark)
public class StringEmptyBenchmark {
@Param({"", "not empty"})
String string;
@Benchmark
public boolean isEmpty() {
return string.isEmpty();
}
@Benchmark
public boolean equalsEmpty() {
return "".equals(string);
}
} |
|
Flaky test? This passes locally. Rerun CI? |
Codecov Report
@@ Coverage Diff @@
## master #7468 +/- ##
=============================================
- Coverage 71.93% 29.07% -42.87%
=============================================
Files 1519 1510 -9
Lines 75341 74994 -347
Branches 10985 10947 -38
=============================================
- Hits 54198 21804 -32394
- Misses 17498 51207 +33709
+ Partials 3645 1983 -1662
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Jackie-Jiang
left a comment
There was a problem hiding this comment.
LGTM. Re-run the tests. I feel the test failure is caused by float ser/de not returning the same result - f != Float.parseFloat(String.format("%f", f))
Good spot, that's worth fixing before it happens again. |
Description
The vast majority if not all of these will be benign, but this change set prevents emptiness checks from becoming bottlenecks if collection implementation is changed. Applies similar changes to manual emptiness checks performed on
Strings.Upgrade Notes
Does this PR prevent a zero down-time upgrade? (Assume upgrade order: Controller, Broker, Server, Minion)
backward-incompat, and complete the section below on Release Notes)Does this PR fix a zero-downtime upgrade introduced earlier?
backward-incompat, and complete the section below on Release Notes)Does this PR otherwise need attention when creating release notes? Things to consider:
release-notesand complete the section on Release Notes)Release Notes
Documentation