From d546b00e22c046cb4e52654322989840139a3c63 Mon Sep 17 00:00:00 2001 From: ejakowatz Date: Mon, 18 Nov 2002 03:47:48 +0000 Subject: [PATCH] Undid the oh-so-1337 utf_char_len "optimization" (which is not only slower, but doesn't handle invalid UTF-8 strings correctly) in CountChars(). git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2002 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/support/String.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/kits/support/String.cpp b/src/kits/support/String.cpp index f8c9aa73a1..5105ed8d9f 100644 --- a/src/kits/support/String.cpp +++ b/src/kits/support/String.cpp @@ -88,6 +88,9 @@ BString::CountChars() const int32 count = 0; const char *ptr = String(); +#if 0 + // ejaesler: Left in memoriam of one man's foolish disregard for the + // maxim "Premature optimization is the root of all evil" while (*ptr) { // Jump to next UTF8 character @@ -95,7 +98,7 @@ BString::CountChars() const ptr += utf8_char_len(*ptr); count++; } -#if 0 +#endif while (*ptr++) { count++; @@ -103,7 +106,6 @@ BString::CountChars() const // Jump to next UTF8 character for (; (*ptr & 0xc0) == 0x80; ptr++); } -#endif return count; }