Uploaded image for project: 'Apache Avro'
  1. Apache Avro
  2. AVRO-1074

Suggested optimization for Utf8.length()

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.6.3
    • 1.7.0
    • java
    • None

    Description

      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:

      return toString().length;

      I believe this could easily get optimized to return this instead:

      return length == 0 ? 0 : toString().length();

      Thus avoiding the need to create the string representation for this common use case (and scenario).

      Attachments

        1. AVRO-1074.patch
          0.5 kB
          Doug Cutting

        Activity

          People

            cutting Doug Cutting
            hernan.otero Hernan Otero
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: