Solr
  1. Solr
  2. SOLR-7983

Utils.toUTF8 uses larger buffer than necessary for holding UTF8 data

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Trivial Trivial
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 5.4, 6.0
    • Component/s: None
    • Labels:
      None

      Description

      Method in question:

      public static byte[] toUTF8(CharArr out) {
          byte[] arr = new byte[out.size() << 2]; // is 4x the real worst-case upper-bound?
          int nBytes = ByteUtils.UTF16toUTF8(out, 0, out.size(), arr, 0);
          return Arrays.copyOf(arr, nBytes);
        }
      

      The byte array should be at most out.size() * 3.

        Activity

        Hide
        ASF subversion and git services added a comment -

        Commit 1698160 from shalin@apache.org in branch 'dev/trunk'
        [ https://svn.apache.org/r1698160 ]

        SOLR-7983: Utils.toUTF8 uses shorter buffer than necessary for holding UTF8 data

        Show
        ASF subversion and git services added a comment - Commit 1698160 from shalin@apache.org in branch 'dev/trunk' [ https://svn.apache.org/r1698160 ] SOLR-7983 : Utils.toUTF8 uses shorter buffer than necessary for holding UTF8 data
        Hide
        ASF subversion and git services added a comment -

        Commit 1698162 from shalin@apache.org in branch 'dev/trunk'
        [ https://svn.apache.org/r1698162 ]

        SOLR-7983: Adding changelog entry

        Show
        ASF subversion and git services added a comment - Commit 1698162 from shalin@apache.org in branch 'dev/trunk' [ https://svn.apache.org/r1698162 ] SOLR-7983 : Adding changelog entry
        Hide
        ASF subversion and git services added a comment -

        Commit 1698163 from shalin@apache.org in branch 'dev/branches/branch_5x'
        [ https://svn.apache.org/r1698163 ]

        SOLR-7983: Utils.toUTF8 uses shorter buffer than necessary for holding UTF8 data

        Show
        ASF subversion and git services added a comment - Commit 1698163 from shalin@apache.org in branch 'dev/branches/branch_5x' [ https://svn.apache.org/r1698163 ] SOLR-7983 : Utils.toUTF8 uses shorter buffer than necessary for holding UTF8 data
        Hide
        Yonik Seeley added a comment - - edited

        I think you mean larger than necessary
        Anyway, it's a minor optimization, not a bug.

        Show
        Yonik Seeley added a comment - - edited I think you mean larger than necessary Anyway, it's a minor optimization, not a bug.
        Hide
        Shalin Shekhar Mangar added a comment -

        Haha, yes, of course. I am not reading right I'll fix the description and the entry in CHANGES.txt

        Show
        Shalin Shekhar Mangar added a comment - Haha, yes, of course. I am not reading right I'll fix the description and the entry in CHANGES.txt
        Hide
        ASF subversion and git services added a comment -

        Commit 1698167 from shalin@apache.org in branch 'dev/trunk'
        [ https://svn.apache.org/r1698167 ]

        SOLR-7983: Fixing changelog entry and moving it to optimizations section

        Show
        ASF subversion and git services added a comment - Commit 1698167 from shalin@apache.org in branch 'dev/trunk' [ https://svn.apache.org/r1698167 ] SOLR-7983 : Fixing changelog entry and moving it to optimizations section
        Hide
        ASF subversion and git services added a comment -

        Commit 1698168 from shalin@apache.org in branch 'dev/branches/branch_5x'
        [ https://svn.apache.org/r1698168 ]

        SOLR-7983: Fixing changelog entry and moving it to optimizations section

        Show
        ASF subversion and git services added a comment - Commit 1698168 from shalin@apache.org in branch 'dev/branches/branch_5x' [ https://svn.apache.org/r1698168 ] SOLR-7983 : Fixing changelog entry and moving it to optimizations section

          People

          • Assignee:
            Shalin Shekhar Mangar
            Reporter:
            Shalin Shekhar Mangar
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development