axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject cvs commit: xml-axis/java/src/org/apache/axis/encoding TypeMappingRegistry.java
Date Wed, 12 Dec 2001 01:20:54 GMT
dug         01/12/11 17:20:54

  Modified:    java/src/org/apache/axis/encoding TypeMappingRegistry.java
  Log:
  Do a better job of checking - ie. don't create a vector right away.
  
  Revision  Changes    Path
  1.38      +25 -16    xml-axis/java/src/org/apache/axis/encoding/TypeMappingRegistry.java
  
  Index: TypeMappingRegistry.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/TypeMappingRegistry.java,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- TypeMappingRegistry.java	2001/12/12 00:31:43	1.37
  +++ TypeMappingRegistry.java	2001/12/12 01:20:54	1.38
  @@ -243,23 +243,32 @@
           throws IOException
       {
           if (value != null) {
  -            Vector classes = new Vector();
  -            classes.add( value.getClass() );
  -    
  -            while( classes.size() != 0 ) {
  -                Class _class = (Class) classes.remove( 0 );
  -                Serializer ser = getSerializer(_class);
  -                if ( ser != null ) {
  -                    QName type = getTypeQName(_class);
  -                    attributes = setTypeAttribute(attributes, type, context);
  -                    ser.serialize(name, attributes, value, context);
  -                    return;
  +            Serializer  ser     = null ;
  +            Class       _class  = null ;
  +
  +            // Check the most common case first
  +            ser = getSerializer( _class = value.getClass() );
  +            if ( ser == null ) {
  +                Vector  classes = new Vector();
  +                classes.add( _class );
  +        
  +                while( classes.size() != 0 ) {
  +                    _class = (Class) classes.remove( 0 );
  +                    if ( (ser = getSerializer(_class)) != null ) break ;
  +                    if ( classes == null ) classes = new Vector();
  +                    Class[] ifaces = _class.getInterfaces();
  +                    for (int i = 0 ; i < ifaces.length ; i++ ) 
  +                        classes.add( ifaces[i] );
  +                    _class = _class.getSuperclass();
  +                    if ( _class != null ) classes.add( _class );
                   }
  -                Class[] ifaces = _class.getInterfaces();
  -                for (int i = 0 ; i < ifaces.length ; i++ ) 
  -                    classes.add( ifaces[i] );
  -                _class = _class.getSuperclass();
  -                if ( _class != null ) classes.add( _class );
  +            }
  +
  +            if ( ser != null ) {
  +                QName type = getTypeQName(_class);
  +                attributes = setTypeAttribute(attributes, type, context);
  +                ser.serialize(name, attributes, value, context);
  +                return;
               }
   
               throw new IOException(JavaUtils.getMessage("noSerializer00",
  
  
  

Mime
View raw message