craig,

i have efficiency questions about ConvertUtils.convert...
isn't it true that the vm loads these class object once:
    java.lang.Boolean, java.lang.String, Boolean.TYPE, etc.

isn't it more efficient to just compare class objects rather playing
with their string representations?  

for example (Version 1):

        if (java.lang.String.class.equals(clazz) {
            if (value == null)
                return ((String) null);
            else
                return (value);
        } else if (java.lang.Boolean.class.equals(clazz) ||
                   java.lang.Boolean.TYPE.equals(clazz) {
            return (convertBoolean(value));
        } else if (java.lang.Byte.class.equals(clazz) ||
                   java.lang.Byte.TYPE.equals(clazz){
            return (convertByte(value));
        .
        .
        .

-OR (Version 2):-

        if (java.lang.String.class == clazz) {
            if (value == null)
                return ((String) null);
            else
                return (value);
        } else if (java.lang.Boolean.class == clazz ||
                   java.lang.Boolean.TYPE == clazz) {
            return (convertBoolean(value));
        } else if (java.lang.Byte.class == clazz ||
                   java.lang.Byte.TYPE == clazz ){
            return (convertByte(value));
        .
        .
        .


are there some issues with the class loader dumping and reloading these
class objects from memory that would make this type of optimization 
in this case dangerous or foolish?

also, since this is a big cascading if/else if statement, shouldn't
the else ifs be ordered according to the practical probability of using
a particular data type.  in my opinion, integer, long, float, and
double are probably used more often than byte and char and should 
therefore be checked ahead of them.


e
-- 
_______________________________________________________________________
Elod Horvath ('e')       /      ITFAIS Records (http://www.itfais.com/)

Reply via email to