Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: Nightly Builds
    • Fix Version/s: None
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

      Description

      Hello,

      I think that in BeanPropertyPointer.java there is an unnecessary use of
      reflection.

      If you get a member of a collection then the collection will be
      fetched twice through reflection.

      The SimplePathInterpreter.java has the following code :

      if (index >= 0 && index < pointer.getLength())

      { pointer.setIndex(index); return pointer.getValuePointer(); }

      The pointer.getLength() will set the 'baseValue' in BeanPropertyPointer.
      The pointer.getValuePointer() will wet the 'value' in BeanPropertyPointer.

      Both will do reflection.

      getValuePointer() calls getNode().
      getNodeValue() doesn't use the 'baseValue' and I think it can !

      So I changed getNode() into :

      public Object getNode(){
      if (value == UNINITIALIZED){
      PropertyDescriptor pd = getPropertyDescriptor();
      if (pd == null)

      { value = null; }

      else {
      getBaseValue();

      if(baseValue != null) {
      if (index == WHOLE_COLLECTION)

      { value = baseValue; }

      else if (index >= 0 && index < getLength())

      { value = ValueUtils.getValue(baseValue, index); }

      }
      }
      }
      return value;
      }

      Kees.

        Activity

        Hide
        Dmitri Plotnikov added a comment -

        I applied a path very similar to the suggested one. The new code is:

        public Object getNode(){
        if (value == UNINITIALIZED){
        Object baseValue = getBaseValue();
        if (index == WHOLE_COLLECTION)

        { value = baseValue; }

        else if (value != null && index >= 0 && index < getLength())

        { value = ValueUtils.getValue(baseValue, index); }

        else

        { value = null; }

        }
        return value;
        }

        Show
        Dmitri Plotnikov added a comment - I applied a path very similar to the suggested one. The new code is: public Object getNode(){ if (value == UNINITIALIZED){ Object baseValue = getBaseValue(); if (index == WHOLE_COLLECTION) { value = baseValue; } else if (value != null && index >= 0 && index < getLength()) { value = ValueUtils.getValue(baseValue, index); } else { value = null; } } return value; }

          People

          • Assignee:
            Unassigned
            Reporter:
            Kees Kuip
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development