GraphicsDefs: Do not cast structs to integers to compare them.

That requires more padding (1 byte vs 4 or 8 depending on integer size),
so just use regular loops and chained ==s.

Caught by Clang. No functional change intended.
This commit is contained in:
Augustin Cavalier
2017-12-01 20:26:20 -05:00
parent 220a7208a3
commit d3abf525c5
+10 -5
View File
@@ -19,9 +19,11 @@ typedef struct pattern {
inline bool inline bool
operator==(const pattern& a, const pattern& b) operator==(const pattern& a, const pattern& b)
{ {
uint64* pa = (uint64*)a.data; for (int i = 0; i < 8; i++) {
uint64* pb = (uint64*)b.data; if (a.data[i] != b.data[i])
return (*pa == *pb); return false;
}
return true;
} }
@@ -62,13 +64,16 @@ typedef struct rgb_color {
inline bool inline bool
operator==(const rgb_color& other) const operator==(const rgb_color& other) const
{ {
return *(const uint32 *)this == *(const uint32 *)&other; return red == other.red
&& green == other.green
&& blue == other.blue
&& alpha == other.alpha;
} }
inline bool inline bool
operator!=(const rgb_color& other) const operator!=(const rgb_color& other) const
{ {
return *(const uint32 *)this != *(const uint32 *)&other; return !(*this == other);
} }
inline rgb_color& inline rgb_color&