apache / lucene

Apache Lucene open-source search software
https://lucene.apache.org/
Apache License 2.0
2.67k stars 1.03k forks source link

Code Refactoring in Field [LUCENE-8486] #9532

Open asfimport opened 6 years ago

asfimport commented 6 years ago

1) Remove Unnecessary Boxing

As I know, Explicit manual boxing is unnecessary after Java 5. It can be safely removed.

 

Before :

// After Line 352
public void setByteValue(byte value) {
  ...
  fieldsData = Byte.valueOf(value);
}

public void setShortValue(short value) {
  ...
  fieldsData = Short.valueOf(value);
}

public void setIntValue(int value) {
  ...
  fieldsData = Integer.valueOf(value);
}

public void setLongValue(long value) {
  ...
  fieldsData = Long.valueOf(value);
}

public void setFloatValue(float value) {
  ...
  fieldsData = Float.valueOf(value);
}

public void setDoubleValue(double value) {
  ...
  fieldsData = Double.valueOf(value);
}

 

After :

// After Line 352
public void setByteValue(byte value) {
  ...
  fieldsData = value;
}

public void setShortValue(short value) {
  ...
  fieldsData = value;
}

public void setIntValue(int value) {
  ...
  fieldsData = value;
}

public void setLongValue(long value) {
  ...
  fieldsData = value;
}

public void setFloatValue(float value) {
  ...
  fieldsData = value;
}

public void setDoubleValue(double value) {
  ...
  fieldsData = value;
}

 

2) Unnecessary static deletion in Store enum

According to https://docs.oracle.com/javase/specs/jls/se8/html/jls-8.html#jls-8.9, "A nested enum type is implicitly static. It is permitted for the declaration of a nested enum type to redundantly specify the static modifier."

So I made the following changes.

 

Before:

// Line 600 method
public static enum Store {

  YES,

  NO
}

 

After:

// Line 600 method
public enum Store {

  YES,

  NO
}

Migrated from LUCENE-8486 by Namgyu Kim (@danmuzi) Attachments: LUCENE-8486.patch

asfimport commented 6 years ago

Lucene/Solr QA (migrated from JIRA)

-1 overall
Vote Subsystem Runtime Comment
Prechecks
-1 test4tests 0m 0s The patch doesn't appear to include any new or modified tests. Please justify why no new tests are needed for this patch. Also please list what manual steps were performed to verify this patch.
master Compile Tests
+1 compile 0m 21s master passed
Patch Compile Tests
+1 compile 0m 18s the patch passed
+1 javac 0m 18s the patch passed
+1 Release audit (RAT) 0m 18s the patch passed
+1 Check forbidden APIs 0m 18s the patch passed
+1 Validate source patterns 0m 18s the patch passed
Other Tests
+1 unit 11m 18s core in the patch passed.
13m 32s
Subsystem Report/Notes
JIRA Issue LUCENE-8486
JIRA Patch URL https://issues.apache.org/jira/secure/attachment/12938504/LUCENE-8486.patch
Optional Tests compile javac unit ratsources checkforbiddenapis validatesourcepatterns
uname Linux lucene1-us-west 4.4.0-130-generic #156\~14.04.1-Ubuntu SMP Thu Jun 14 13:51:47 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
Build tool ant
Personality /home/jenkins/jenkins-slave/workspace/PreCommit-LUCENE-Build/sourcedir/dev-tools/test-patch/lucene-solr-yetus-personality.sh
git revision master / b4a1548
ant version: Apache Ant(TM) version 1.9.3 compiled on July 24 2018
Default Java 1.8.0_172
Test Results https://builds.apache.org/job/PreCommit-LUCENE-Build/85/testReport/
modules C: lucene/core U: lucene/core
Console output https://builds.apache.org/job/PreCommit-LUCENE-Build/85/console
Powered by Apache Yetus 0.7.0 http://yetus.apache.org

This message was automatically generated.