commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 13108] New: - unnecessary reflection
Date Sat, 28 Sep 2002 08:39:53 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=13108>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=13108

unnecessary reflection

           Summary: unnecessary reflection
           Product: Commons
           Version: Nightly Builds
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Enhancement
          Priority: Other
         Component: JXPath
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: keeskuip@technologist.com


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.

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message