#12 Performance optimization for Name.consumeNextObjectField()

open
nobody
None
5
2006-09-08
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

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks