Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-22849

Reuse skip_trailing_space() in my_hash_sort_utf8mbX

    XMLWordPrintable

    Details

      Description

      Replace the slow loop in my_hash_sort_utf8mbX() to the fast skip_trailing_spaces(), which consumes 8 bytes in one iteration, as follows:

      diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c
      index b8e71b1f7a9..7434f968383 100644
      --- a/strings/ctype-utf8.c
      +++ b/strings/ctype-utf8.c
      @@ -4992,13 +4992,11 @@ static void my_hash_sort_utf8mb3_nopad(CHARSET_INFO *cs, const uchar *s, size_t
       static void my_hash_sort_utf8mb3(CHARSET_INFO *cs, const uchar *s, size_t slen,
                                        ulong *nr1, ulong *nr2)
       {
      -  const uchar *e= s+slen;
         /*
           Remove end space. We have to do this to be able to compare
           'A ' and 'A' as identical
         */
      -  while (e > s && e[-1] == ' ')
      -    e--;
      +  const uchar *e= skip_trailing_space(s, slen);
         my_hash_sort_utf8mb3_nopad(cs, s, e - s, nr1, nr2);
       }
       
      @@ -7436,13 +7434,11 @@ static void
       my_hash_sort_utf8mb4(CHARSET_INFO *cs, const uchar *s, size_t slen,
                            ulong *nr1, ulong *nr2)
       {
      -  const uchar *e= s + slen;
         /*
           Remove end space. We do this to be able to compare
           'A ' and 'A' as identical
         */
      -  while (e > s && e[-1] == ' ')
      -    e--;
      +  const uchar *e= skip_trailing_space(s, slen);
         my_hash_sort_utf8mb4_nopad(cs, s, e - s, nr1, nr2);
       }
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              bar Alexander Barkov
              Reporter:
              bar Alexander Barkov
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: