Uploaded image for project: 'Lucene - Core'
  1. Lucene - Core
  2. LUCENE-8486

Code Refactoring in Field

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Patch Available
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: core/other
    • Labels:
    • Lucene Fields:
      New

      Description

      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
      }

        Attachments

        1. LUCENE-8486.patch
          3 kB
          Namgyu Kim

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              danmuzi Namgyu Kim
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: