-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Use equalsTo() for string comparison instead of == #16714
base: main
Are you sure you want to change the base?
Conversation
Previous PR opensearch-project#16461 Signed-off-by: Dmitry Kryukov <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #16714 +/- ##
============================================
- Coverage 72.51% 72.12% -0.40%
+ Complexity 65562 65205 -357
============================================
Files 5318 5318
Lines 303945 303945
Branches 43976 43976
============================================
- Hits 220413 219221 -1192
- Misses 65798 66790 +992
- Partials 17734 17934 +200 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
@@ -126,7 +126,7 @@ public void add(Term[] terms) { | |||
*/ | |||
public void add(Term[] terms, int position) { | |||
for (int i = 0; i < terms.length; i++) { | |||
if (terms[i].field() != field) { | |||
if (!Objects.equals(terms[i].field(), field)) { |
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.
field
is a non-nullable object. Why not directly use field.equals(..)
?
@@ -105,7 +106,7 @@ public List<String> resolveIndexAbstractions( | |||
|
|||
// we always need to check for date math expressions | |||
final String dateMathName = indexNameExpressionResolver.resolveDateMathExpression(indexAbstraction); | |||
if (dateMathName != indexAbstraction) { | |||
if (!Objects.equals(dateMathName, indexAbstraction)) { |
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 don't think either of the 2 is null - can you verify once. If they are non-null than s1.equals(s2)
will be slightly (unnoticeable but still) faster.
@@ -105,7 +106,7 @@ public List<String> resolveIndexAbstractions( | |||
|
|||
// we always need to check for date math expressions | |||
final String dateMathName = indexNameExpressionResolver.resolveDateMathExpression(indexAbstraction); | |||
if (dateMathName != indexAbstraction) { | |||
if (!Objects.equals(dateMathName, indexAbstraction)) { | |||
assert dateMathName.equals(indexAbstraction) == false; |
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'm wondering why do we even need this assertion. Why can remove this since that's the entry criteria in this block.
Previous PR #16461
Got spoiled because of rebase