From 7d62a1da89e40dde38eb902bd84b1c9efa938823 Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Sat, 23 Feb 2008 15:41:22 +0000 Subject: [PATCH] In the last commit I introduced a bug: charCount wasn't incremented correctly in some cases inside HashEscapements(). Also, when looking for a value in the hash, we checked the same position twice in some cases (did not cause any problem, was just a bit slower). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24079 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/textview_support/WidthBuffer.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/kits/interface/textview_support/WidthBuffer.cpp b/src/kits/interface/textview_support/WidthBuffer.cpp index b8775e145d..d9bc401701 100644 --- a/src/kits/interface/textview_support/WidthBuffer.cpp +++ b/src/kits/interface/textview_support/WidthBuffer.cpp @@ -216,6 +216,7 @@ _BWidthBuffer_::InsertTable(const BFont *font) return position; } + /*! \brief Gets the escapement for the given charachter. \param value An integer which uniquely identifies a charachter. \param index The index of the table to search. @@ -300,13 +301,7 @@ _BWidthBuffer_::HashEscapements(const char *inText, int32 numChars, int32 textLe const uint32 value = CharToCode(text, charLen); uint32 hashed = Hash(value) & (table.tableCount - 1); - uint32 found = widths[hashed].code; - - if (found == value) { - text += charLen; - continue; - } - + uint32 found; while ((found = widths[hashed].code) != kInvalidCode) { if (found == value) break; @@ -325,6 +320,7 @@ _BWidthBuffer_::HashEscapements(const char *inText, int32 numChars, int32 textLe // the total size. if (table.tableCount * 2 / 3 <= table.hashCount) { const int32 newSize = table.tableCount * 2; + table.tableCount = newSize; // Create and initialize a new hash table hashed_escapement *newWidths = new hashed_escapement[newSize]; @@ -338,10 +334,8 @@ _BWidthBuffer_::HashEscapements(const char *inText, int32 numChars, int32 textLe newPos = 0; } newWidths[newPos] = widths[oldPos]; - } } - table.tableCount = newSize; // Delete the old table, and put the new pointer into the _width_table_ delete[] widths;