Menu

#12 Performance optimization for Name.consumeNextObjectField()

None
closed
nobody
None
5
2018-08-01
2006-09-08
Anonymous
No

/*
Keep adding parts until we have a class
*/
Class clas = null;
int i = 1;
String className = null;

// FIXME: OPTIMIZE THIS FOR PROGRAMMERS TAKING CARE OF
JAVA NAMING CONVENTIONS
// for(; i <= countParts
(evalName); i++)
// {
// className = prefix
(evalName, i);
// if ( (clas =
namespace.getClass(className)) != null )
// break;
// }
// first search for a classname that starts with an
upper case character
int index = 0;
while ( index < evalName.length() ) {
if ( Character.isUpperCase(evalName.charAt
(index)) ) {
className = prefix(evalName, i);
if ( (clas = namespace.getClass
(className)) != null )
break;
}
if ( (index = evalName.indexOf('.' ,index+1))
< 0 ) break;
++index;
++i;
}
// if the search above didn't succeed, revert to non-
optimized behaviour
if ( clas == null ) {
int numParts = countParts(evalName);
for(i = 1; i <= numParts; i++) {
className = prefix(evalName, i);
if ( (clas = namespace.getClass
(className)) != null )
break;
}
}
// FIXME: END OF OPTIMIZATION

if ( clas != null ) {
return completeRound(
className,
suffix( evalName, countParts(evalName)-
i ),
new ClassIdentifier(clas)
);
}

Discussion

  • nickl-

    nickl- - 2018-08-01
    • status: open --> closed
    • Group: -->
     
  • nickl-

    nickl- - 2018-08-01

    Ticket has been migrated to github.
    Please follow up on this over here: https://github.com/beanshell/beanshell/issues/118

     

Log in to post a comment.