Skip to content

Commit 71444f1

Browse files
committed
Minor optimization to avoid silly double-calls to very expensive lookup methods
1 parent 82c377e commit 71444f1

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

avro/src/main/java/com/fasterxml/jackson/dataformat/avro/deser/AvroReaderFactory.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,24 +66,23 @@ public ScalarDecoder createScalarValueDecoder(Schema type)
6666
case FLOAT:
6767
return READER_FLOAT;
6868
case INT:
69-
if (AvroSchemaHelper.getTypeId(type) != null) {
70-
return new IntReader(AvroSchemaHelper.getTypeId(type));
69+
{
70+
final String typeId = AvroSchemaHelper.getTypeId(type);
71+
return (typeId != null) ? new IntReader(typeId) : READER_INT;
7172
}
72-
return READER_INT;
7373
case LONG:
7474
return READER_LONG;
7575
case NULL:
7676
return READER_NULL;
7777
case STRING:
78-
if (AvroSchemaHelper.getTypeId(type) != null) {
79-
return new StringReader(AvroSchemaHelper.getTypeId(type));
78+
{
79+
final String typeId = AvroSchemaHelper.getTypeId(type);
80+
return (typeId != null) ? new StringReader(typeId) : READER_STRING;
8081
}
81-
return READER_STRING;
8282
case UNION:
83-
/* Union is a "scalar union" if all the alternative types
84-
* are scalar. One common type is that of "nullable" one,
85-
* but general handling should work just fine.
86-
*/
83+
// Union is a "scalar union" if all the alternative types
84+
// are scalar. One common type is that of "nullable" one,
85+
// but general handling should work just fine.
8786
List<Schema> types = type.getTypes();
8887
{
8988
ScalarDecoder[] readers = new ScalarDecoder[types.size()];

0 commit comments

Comments
 (0)