atos1990 / orika

Automatically exported from code.google.com/p/orika
0 stars 0 forks source link

MapperFacadeImpl - unenhancer when usage #12

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
In the MapperFacadeImpl#convert method unenhancer is always called, but the 
unenhanced class is only used when no converterId was specified. This could be 
easily fixed by moving the call into the 'if' body.

    public <S, D> D convert(S source, Type<S> sourceType, Type<D> destinationType, String converterId) {
        Converter<S, D> converter;
        ConverterFactory converterFactory = mapperFactory.getConverterFactory();
        if (converterId == null) {
        final Type<? extends Object> sourceClass = unenhanceStrategy.unenhanceType(source, sourceType);
            converter = (Converter<S, D>) converterFactory.getConverter(sourceClass, destinationType);
        } else {
            converter = (Converter<S, D>) converterFactory.getConverter(converterId);
        }

        return converter.convert(source, destinationType);
    }

This gives a small performance improvement when using named converters.

Original issue reported on code.google.com by lighteater on 17 Apr 2012 at 12:15

GoogleCodeExporter commented 9 years ago
Great! 
We're thinking also about moving converter resolution to "generate time" so in 
runtime (mapping) we can have a simple O(1) complexity

Thank you if you have any suggestions please do not hesitate :)

Original comment by elaat...@gmail.com on 20 Apr 2012 at 2:58

GoogleCodeExporter commented 9 years ago
Converter has been moved to "generate time" in the 1.2.0 branch; 
this suggested change is applied in that branch as well.

Original comment by matt.deb...@gmail.com on 4 Aug 2012 at 4:53