From 7bf8fcfab4a4cc0cce805ded6f42146a003adb7c Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Wed, 2 Nov 2011 09:19:24 +0000 Subject: [PATCH] Make rect data part of union as suggested by Ingo. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43100 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/shared/Variant.h | 13 +++++++------ src/kits/shared/Variant.cpp | 19 ++++++++++--------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/headers/private/shared/Variant.h b/headers/private/shared/Variant.h index bbbaa7a6ae..eac072dd3b 100644 --- a/headers/private/shared/Variant.h +++ b/headers/private/shared/Variant.h @@ -159,13 +159,14 @@ private: void* fPointer; char* fString; BReferenceable* fReferenceable; - uint8 fBytes[8]; + struct { + float left; + float top; + float right; + float bottom; + } fRect; + uint8 fBytes[sizeof(float) * 4]; }; - - float fLeft; - float fTop; - float fRight; - float fBottom; }; diff --git a/src/kits/shared/Variant.cpp b/src/kits/shared/Variant.cpp index d81df4b269..7d32e42c1d 100644 --- a/src/kits/shared/Variant.cpp +++ b/src/kits/shared/Variant.cpp @@ -177,8 +177,9 @@ BVariant::operator==(const BVariant& other) const return fString == other.fString; return strcmp(fString, other.fString) == 0; case B_RECT_TYPE: - return BRect(fLeft, fTop, fRight, fBottom) == BRect( - other.fLeft, other.fTop, other.fRight, other.fBottom); + return BRect(fRect.left, fRect.top, fRect.right, fRect.bottom) + == BRect(other.fRect.left, other.fRect.top, other.fRect.right, + other.fRect.bottom); default: return false; } @@ -316,7 +317,7 @@ BVariant::ToDouble() const BRect BVariant::ToRect() const { - return BRect(fLeft, fTop, fRight, fBottom); + return BRect(fRect.left, fRect.top, fRect.right, fRect.bottom); } @@ -405,8 +406,8 @@ BVariant::AddToMessage(BMessage& message, const char* fieldName) const case B_STRING_TYPE: return message.AddString(fieldName, fString); case B_RECT_TYPE: - return message.AddRect(fieldName, BRect(fLeft, fTop, fRight, - fBottom)); + return message.AddRect(fieldName, BRect(fRect.left, fRect.top, + fRect.right, fRect.bottom)); default: return B_UNSUPPORTED; } @@ -633,10 +634,10 @@ BVariant::_SetTo(float left, float top, float right, float bottom) { fType = B_RECT_TYPE; fFlags = 0; - fLeft = left; - fTop = top; - fRight = right; - fBottom = bottom; + fRect.left = left; + fRect.top = top; + fRect.right = right; + fRect.bottom = bottom; }