Uploaded image for project: 'Commons JXPath'
  1. Commons JXPath
  2. JXPATH-55

unnecessary reflection

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • Nightly Builds
    • None
    • None
    • Operating System: All
      Platform: All

    • 13108

    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.

      Attachments

        Activity

          People

            Unassigned Unassigned
            keeskuip@technologist.com Kees Kuip
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: