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
This commit is contained in:
parent
eb64dfc217
commit
d546b00e22
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user