snichol 2002/10/30 06:33:02 Modified: java/src/org/apache/soap/util/xml QName.java XMLJavaMappingRegistry.java Log: Require fewer memory allocations by doing four things QName.java: Use StringBuffer rather than String concatenation in toString. XMLJavaMappingRegistry: Use bare encodingStyleURI as key when QName or Class is null, submitted by Pavel Ausianik <[EMAIL PROTECTED]>. Use Class#getName rather than Class#toString, submitted by Pavel Ausianik <[EMAIL PROTECTED]>. Don't create a key in mapTypes unless it is going to be used. Revision Changes Path 1.8 +2 -1 xml-soap/java/src/org/apache/soap/util/xml/QName.java Index: QName.java =================================================================== RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/util/xml/QName.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- QName.java 4 Oct 2002 13:26:03 -0000 1.7 +++ QName.java 30 Oct 2002 14:33:02 -0000 1.8 @@ -144,6 +144,7 @@ public String toString() { - return namespaceURI + ':' + localPart; + return new StringBuffer(namespaceURI.length() + 1 + localPart.length()) + .append(namespaceURI).append(':').append(localPart).toString(); } } 1.11 +26 -7 xml-soap/java/src/org/apache/soap/util/xml/XMLJavaMappingRegistry.java Index: XMLJavaMappingRegistry.java =================================================================== RCS file: /home/cvs/xml-soap/java/src/org/apache/soap/util/xml/XMLJavaMappingRegistry.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- XMLJavaMappingRegistry.java 23 Oct 2002 19:35:19 -0000 1.10 +++ XMLJavaMappingRegistry.java 30 Oct 2002 14:33:02 -0000 1.11 @@ -127,16 +127,18 @@ public void mapTypes(String encodingStyleURI, QName elementType, Class javaType, Serializer s, Deserializer ds) { - String java2XMLKey = getKey(javaType, encodingStyleURI); - String xml2JavaKey = getKey(elementType, encodingStyleURI); + String java2XMLKey = null; + String xml2JavaKey = null; if (s != null) { + java2XMLKey = getKey(javaType, encodingStyleURI); sReg.put(java2XMLKey, s); } if (ds != null) { + xml2JavaKey = getKey(elementType, encodingStyleURI); dsReg.put(xml2JavaKey, ds); } @@ -177,7 +179,7 @@ } else { - java2XMLKey = getKey(null, encodingStyleURI); + java2XMLKey = getKey((Class) null, encodingStyleURI); return (Serializer)sReg.get(java2XMLKey); } } @@ -235,7 +237,7 @@ } else { - xml2JavaKey = getKey(null, encodingStyleURI); + xml2JavaKey = getKey((QName) null, encodingStyleURI); return (Deserializer)dsReg.get(xml2JavaKey); } } @@ -400,13 +402,30 @@ /** * Creates a key for the registry Hashtables. * - * @param type The Java type (as a Class) or the XML type (as a QName). + * @param type The XML type. + * @param encodingStyleURI The encoding style. + * @return The key. + */ + private static String getKey(QName type, String encodingStyleURI) + { + if (type == null) + return encodingStyleURI; + String strObj = type.toString(); + return new StringBuffer(strObj.length() + 3 + encodingStyleURI.length()).append(strObj).append(" + ").append(encodingStyleURI).toString(); + } + + /** + * Creates a key for the registry Hashtables. + * + * @param type The Java type. * @param encodingStyleURI The encoding style. * @return The key. */ - private static String getKey(Object type, String encodingStyleURI) + private static String getKey(Class type, String encodingStyleURI) { - String strObj = String.valueOf(type); + if (type == null) + return encodingStyleURI; + String strObj = type.getName(); return new StringBuffer(strObj.length() + 3 + encodingStyleURI.length()).append(strObj).append(" + ").append(encodingStyleURI).toString(); }
-- To unsubscribe, e-mail: <mailto:soap-dev-unsubscribe@;xml.apache.org> For additional commands, e-mail: <mailto:soap-dev-help@;xml.apache.org>