Source:
<code>public CommonProtos.Reference.Builder serialize(final ContentRef contentRef) { return contentRef.getContentType().accept(new ContentType.Visitor<CommonProtos.Reference.Builder>() { private Builder serializeRef(ContentRef contentRef) { CommonProtos.Reference.Builder ref = CommonProtos.Reference.newBuilder(); ref.setId(contentRef.getId().longValue()); ref.setSource(contentRef.getSource().key()); ref.setType(contentRef.getContentType().toString()); return ref; } @Override public Builder visitBrand(ContentType contentType) { return serializeRef(contentRef); } @Override public Builder visitClip(ContentType contentType) { return visitItem(contentType); } @Override public Builder visitSong(ContentType contentType) { return visitItem(contentType); } @Override public Builder visitFilm(ContentType contentType) { return visitItem(contentType); } @Override public Builder visitEpisode(ContentType contentType) { return visitItem(contentType); } @Override public Builder visitItem(ContentType contentType) { Builder builder = serializeRef(contentRef); ItemRef itemRef = (ItemRef) contentRef; builder.setSort(itemRef.getSortKey()); builder.setUpdated(new DateTimeSerializer().serialize(itemRef.getUpdated())); return builder; } @Override public Builder visitSeries(ContentType contentType) { Builder builder = serializeRef(contentRef); SeriesRef seriesRef = (SeriesRef) contentRef; if (seriesRef.getTitle() != null) { builder.setSort(seriesRef.getTitle()); } if (seriesRef.getSeriesNumber() != null) { builder.setPosition(seriesRef.getSeriesNumber()); } if (seriesRef.getUpdated() != null) { <START> builder.setUpdated(new DateTimeSerializer().serialize(seriesRef.getUpdated())); <END> } if (seriesRef.getCertificates() != null) { ImmutableSet<CommonProtos.Certificate> certs = seriesRef.getCertificates().stream() .map(certificateSerializer::serialize) .collect(ImmutableCollectors.toSet()); builder.addAllCertificates(certs); } if (seriesRef.getReleaseYear() != null) { builder.setReleaseYear(seriesRef.getReleaseYear()); } return builder; } }); }</code><technical_language>object alloc is expensive :(</technical_language>

Target:
public CommonProtos.Reference.Builder serialize(final ContentRef contentRef) { return contentRef.getContentType().accept(new ContentType.Visitor<CommonProtos.Reference.Builder>() { private Builder serializeRef(ContentRef contentRef) { CommonProtos.Reference.Builder ref = CommonProtos.Reference.newBuilder(); ref.setId(contentRef.getId().longValue()); ref.setSource(contentRef.getSource().key()); ref.setType(contentRef.getContentType().toString()); return ref; } @Override public Builder visitBrand(ContentType contentType) { return serializeRef(contentRef); } @Override public Builder visitClip(ContentType contentType) { return visitItem(contentType); } @Override public Builder visitSong(ContentType contentType) { return visitItem(contentType); } @Override public Builder visitFilm(ContentType contentType) { return visitItem(contentType); } @Override public Builder visitEpisode(ContentType contentType) { return visitItem(contentType); } @Override public Builder visitItem(ContentType contentType) { Builder builder = serializeRef(contentRef); ItemRef itemRef = (ItemRef) contentRef; builder.setSort(itemRef.getSortKey()); builder.setUpdated(dateTimeSerializer.serialize(itemRef.getUpdated())); return builder; } @Override public Builder visitSeries(ContentType contentType) { Builder builder = serializeRef(contentRef); SeriesRef seriesRef = (SeriesRef) contentRef; if (seriesRef.getTitle() != null) { builder.setSort(seriesRef.getTitle()); } if (seriesRef.getSeriesNumber() != null) { builder.setPosition(seriesRef.getSeriesNumber()); } if (seriesRef.getUpdated() != null) { builder.setUpdated(dateTimeSerializer.serialize(seriesRef.getUpdated())); } if (seriesRef.getCertificates() != null) { ImmutableSet<CommonProtos.Certificate> certs = seriesRef.getCertificates().stream() .map(certificateSerializer::serialize) .collect(ImmutableCollectors.toSet()); builder.addAllCertificates(certs); } if (seriesRef.getReleaseYear() != null) { builder.setReleaseYear(seriesRef.getReleaseYear()); } return builder; } }); }