[ https://issues.apache.org/jira/browse/AVRO-1074?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Doug Cutting updated AVRO-1074: ------------------------------- Attachment: AVRO-1074.patch Here's a patch that implements Wolfgang's suggestion. Tests pass. > Suggested optimization for Utf8.length() > ---------------------------------------- > > Key: AVRO-1074 > URL: https://issues.apache.org/jira/browse/AVRO-1074 > Project: Avro > Issue Type: Improvement > Components: java > Affects Versions: 1.6.3 > Reporter: Hernan Otero > Fix For: 1.7.0 > > Attachments: AVRO-1074.patch > > > Wanted to suggest a small optimization. It is quite common for applications > to do a quick check (along with null-ness) for 0-length of string-typed > fields. Today's Utf8.length() implementation is: > {code}return toString().length;{code} > I believe this could easily get optimized to return this instead: > {code}return length == 0 ? 0 : toString().length();{code} > Thus avoiding the need to create the string representation for this common > use case (and scenario). -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira