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
This commit is contained in:
@@ -216,6 +216,7 @@ _BWidthBuffer_::InsertTable(const BFont *font)
|
|||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Gets the escapement for the given charachter.
|
/*! \brief Gets the escapement for the given charachter.
|
||||||
\param value An integer which uniquely identifies a charachter.
|
\param value An integer which uniquely identifies a charachter.
|
||||||
\param index The index of the table to search.
|
\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);
|
const uint32 value = CharToCode(text, charLen);
|
||||||
|
|
||||||
uint32 hashed = Hash(value) & (table.tableCount - 1);
|
uint32 hashed = Hash(value) & (table.tableCount - 1);
|
||||||
uint32 found = widths[hashed].code;
|
uint32 found;
|
||||||
|
|
||||||
if (found == value) {
|
|
||||||
text += charLen;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
while ((found = widths[hashed].code) != kInvalidCode) {
|
while ((found = widths[hashed].code) != kInvalidCode) {
|
||||||
if (found == value)
|
if (found == value)
|
||||||
break;
|
break;
|
||||||
@@ -325,6 +320,7 @@ _BWidthBuffer_::HashEscapements(const char *inText, int32 numChars, int32 textLe
|
|||||||
// the total size.
|
// the total size.
|
||||||
if (table.tableCount * 2 / 3 <= table.hashCount) {
|
if (table.tableCount * 2 / 3 <= table.hashCount) {
|
||||||
const int32 newSize = table.tableCount * 2;
|
const int32 newSize = table.tableCount * 2;
|
||||||
|
table.tableCount = newSize;
|
||||||
|
|
||||||
// Create and initialize a new hash table
|
// Create and initialize a new hash table
|
||||||
hashed_escapement *newWidths = new hashed_escapement[newSize];
|
hashed_escapement *newWidths = new hashed_escapement[newSize];
|
||||||
@@ -338,10 +334,8 @@ _BWidthBuffer_::HashEscapements(const char *inText, int32 numChars, int32 textLe
|
|||||||
newPos = 0;
|
newPos = 0;
|
||||||
}
|
}
|
||||||
newWidths[newPos] = widths[oldPos];
|
newWidths[newPos] = widths[oldPos];
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
table.tableCount = newSize;
|
|
||||||
|
|
||||||
// Delete the old table, and put the new pointer into the _width_table_
|
// Delete the old table, and put the new pointer into the _width_table_
|
||||||
delete[] widths;
|
delete[] widths;
|
||||||
|
|||||||
Reference in New Issue
Block a user