You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Doug Cutting (JIRA)" <ji...@apache.org> on 2012/05/18 00:31:09 UTC

[jira] [Resolved] (AVRO-1074) Suggested optimization for Utf8.length()

     [ https://issues.apache.org/jira/browse/AVRO-1074?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Doug Cutting resolved AVRO-1074.
--------------------------------

    Resolution: Fixed
      Assignee: Doug Cutting

I committed this.
                
> 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
>            Assignee: Doug Cutting
>             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