Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dk2k
Copy link
Contributor

@dk2k dk2k commented Nov 23, 2024

Previous PR #16461
Got spoiled because of rebase

Copy link
Contributor

✅ Gradle check result for 17e4cf9: SUCCESS

Copy link

codecov bot commented Nov 23, 2024

Codecov Report

Attention: Patch coverage is 20.00000% with 4 lines in your changes missing coverage. Please review.

Project coverage is 72.12%. Comparing base (c82cd2e) to head (17e4cf9).

Files with missing lines Patch % Lines
...earch/suggest/phrase/NoisyChannelSpellChecker.java 0.00% 0 Missing and 2 partials ⚠️
...h/common/lucene/search/MultiPhrasePrefixQuery.java 0.00% 0 Missing and 1 partial ⚠️
...ons/bucket/composite/UnsignedLongValuesSource.java 0.00% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

@dk2k dk2k marked this pull request as draft November 23, 2024 17:00
@dk2k dk2k marked this pull request as ready for review November 23, 2024 17:00
@@ -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)) {
Copy link
Contributor

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)) {
Copy link
Contributor

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;
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants