1. XStream
  2. XSTR-506

Method com.thoughtworks.xstream.mapper.FieldAliasMapper.key(Class,String) contains performance hotspot


    • Type: Improvement Improvement
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Duplicate
    • Affects Version/s: 1.2.2, 1.3
    • Fix Version/s: None
    • Component/s: Core
    • Labels:
    • JDK version and platform:
      Sun 1.5.0_12 for Windows


      The profiling results for our application (which uses XStream 1.2.2 / 1.3) suggest that the keying mechanism used by the field alias mapper leads to a performance hotspot (in terms of execution time) due to the combination of the two factors number of invocations (the key method is called relatively often during serialization), and costs (in terms of execution time) per invocation, caused by the expensive string operations (implicit use of java.lang.StringBuffer – init, append, toString in the key method).

      I recommend reworking the key mechanism so as to avoid using string operations. Maybe using the parameter object references as a key instead of concatenating their string representations could be a more efficient approach?

      The number of calls to the key method could also be reduced in some instances, e.g. method shouldSerializeMember(Class definedIn, String fieldName) could first check whether fieldsToOmit is empty before constructing the key with which to search the hashset.

        Issue Links


          • Assignee:
            Jörg Schaible
            Stefan Wappler
          • Votes:
            0 Vote for this issue
            0 Start watching this issue


            • Created: