From 3c3b11c3b876b36db7243d53390d02e9ffb3fad1 Mon Sep 17 00:00:00 2001 From: Magne Mahre Date: Wed, 11 Nov 2009 17:03:02 +0100 Subject: Bug #14637: trim trailing spaces processes data only byte wise (From: gkodinov) Use and int * where possible to scan for trailing space in a string instead of always iterating char-by-char. Using the attached benchmark file on a 32 bit Intel Core 2 Duo CPU I've got 43485 ms run with the fix compared to 44373 without it. Backported to 5.6.0 (next-mr-runtime) 6.0-codebase revid: 2476.1362.1 include/m_string.h: scan for space through ints strings/ctype-bin.c: scan for space through ints strings/ctype-latin1.c: scan for space through ints strings/ctype-mb.c: scan for space through ints strings/ctype-simple.c: scan for space through ints --- strings/ctype-latin1.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'strings/ctype-latin1.c') diff --git a/strings/ctype-latin1.c b/strings/ctype-latin1.c index e5333c4101b..dbd91c09637 100644 --- a/strings/ctype-latin1.c +++ b/strings/ctype-latin1.c @@ -678,13 +678,12 @@ void my_hash_sort_latin1_de(CHARSET_INFO *cs __attribute__((unused)), const uchar *key, size_t len, ulong *nr1, ulong *nr2) { - const uchar *end= key+len; + const uchar *end; /* Remove end space. We have to do this to be able to compare 'AE' and 'Ä' as identical */ - while (end > key && end[-1] == ' ') - end--; + end= skip_trailing_space(key, len); for (; key < end ; key++) { -- cgit v1.2.1