[
https://issues.apache.org/jira/browse/AVRO-1074?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13264136#comment-13264136
]
wolfgang hoschek commented on AVRO-1074:
----------------------------------------
An alternative might be for Utf8.toString() to return the "" String constant if
Utf8.length == 0. This avoids having to construct a new String object when
empty on Utf8.toString(). It also efficiently addresses the Utf8.length() use
case brought up by Hernan, so this version might be preferable overall.
> 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
>
>
> 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