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;| </#if> | ||
| for ( Map.Entry<String, AnnotationValue> defaultMethod : defaultValues.entrySet() ) { | ||
| String methodName = defaultMethod.getKey(); | ||
| <#macro fillBuilder gemValueInfo indnet> |
There was a problem hiding this comment.
I think that it'll be better if we move the macro in the bottom. I personally find it a bit weird to have it in the middle.
Also, I think that indnet should be indent, right?
| <#if (gemInfo.gemValueInfos?size < 4)> | ||
| <#list gemInfo.gemValueInfos as gemValueInfo> | ||
| <#if gemValueInfo_index != 0>else </#if>if ( "${gemValueInfo.name}".equals( methodName ) ) { | ||
| <#assign indentString = " "> |
There was a problem hiding this comment.
Why don't we assign this just before we start the <#list?
| switch ( methodName ) { | ||
| <#list gemInfo.gemValueInfos as gemValueInfo> | ||
| case "${gemValueInfo.name}": | ||
| <#assign indentString = " "> |
There was a problem hiding this comment.
Why don't we assign this just before we start the <#list?
That's great |
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.