From 16dc60cf10c334fe5f9bb8452530c5aa20c6a4f6 Mon Sep 17 00:00:00 2001 From: shatty Date: Wed, 3 Nov 2004 09:34:53 +0000 Subject: [PATCH] use struct constructor to provide default initialization values git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9758 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/BTextView/WidthBuffer.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/kits/interface/BTextView/WidthBuffer.cpp b/src/kits/interface/BTextView/WidthBuffer.cpp index da541bd732..aa790e42fb 100644 --- a/src/kits/interface/BTextView/WidthBuffer.cpp +++ b/src/kits/interface/BTextView/WidthBuffer.cpp @@ -39,6 +39,10 @@ struct hashed_escapement { uint32 code; float escapement; + hashed_escapement() { + code = (uint32)-1; + escapement = 0; + } }; @@ -217,11 +221,6 @@ _BWidthBuffer_::InsertTable(const BFont *font) table.tableCount = kTableCount; table.widths = deltas; - for (uint32 i = 0; i < kTableCount; i++) { - deltas[i].code = (uint32)-1; - deltas[i].escapement = 0; - } - int32 position = fItemCount; InsertItemsAt(1, position, &table); @@ -339,10 +338,7 @@ _BWidthBuffer_::HashEscapements(const char *inText, int32 numChars, int32 textLe // Create and initialize a new hash table hashed_escapement *newWidths = new hashed_escapement[newSize]; - for (int32 x = 0; x < newSize; x++) { - newWidths[x].code = (uint32)-1; - newWidths[x].escapement = 0; - } + // Rehash the values, and put them into the new table for (int32 oldPos = 0; oldPos < table->tableCount; oldPos++) { if (widths[oldPos].code != (uint32) -1) {