Conversation
|
I tested the this improvement with mapstruct and found a small improvement (about 100ms for mapstruct-processor in |
filiphr
left a comment
There was a problem hiding this comment.
This reads way better @hduelme. Thanks a lot for the improvements. I've left some comments.
Apart of the comments, I see that we have a lot of values.get( methodName ) and defaultMethod.getValue(). Won't it be a bit better if we assign them at the beginning of the if / switch?
e.g.
String methodName = defaultMethod.getKey();
switch ( methodName ) {
case "myClassWithDefault":
builder.setMyclasswithdefault( GemValue.create( values.get( methodName ), defaultMethod.getValue(), TypeMirror.class ) );
break;Would become
String methodName = defaultMethod.getKey();
AnnotationValue defaultValue = defaultMethod.getValue();
AnnotationValue value = values.get( methodName );
switch ( methodName ) {
case "myClassWithDefault":
builder.setMyclasswithdefault( GemValue.create( value, defaultValue, TypeMirror.class ) );
break;
processor/src/main/resources/org/mapstruct/tools/gem/processor/Gem.ftl
Outdated
Show resolved
Hide resolved
processor/src/main/resources/org/mapstruct/tools/gem/processor/Gem.ftl
Outdated
Show resolved
Hide resolved
processor/src/main/resources/org/mapstruct/tools/gem/processor/Gem.ftl
Outdated
Show resolved
Hide resolved
That's great |
|
@filiphr I've addressed your comments. I agree that moving |
I changed the generated code to use java switch string matching, if there are more than 3 strings to check. For this I extracted the builder fill code into
fillBuildermacro.I although changed the loop iteration to use
entrySet.