From 4a192c319baeb20052d6ddfae27b9c6bd2492b3e Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Wed, 22 Feb 2012 14:54:10 -0800 Subject: [PATCH] ensure mean_sort_cmp adheres to strict weak ordering requirement - more properly fixes #1087 --- src/palette.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/palette.cpp b/src/palette.cpp index f03ecec2e..29d4120d4 100644 --- a/src/palette.cpp +++ b/src/palette.cpp @@ -35,10 +35,11 @@ bool rgba::mean_sort_cmp::operator() (const rgba& x, const rgba& y) const int t2 = (int)y.a + y.r + y.g + y.b; if (t1 != t2) return t1 < t2; - return (((int)x.a - y.a) >> 24) + - (((int)x.r - y.r) >> 16) + - (((int)x.g - y.g) >> 8) + - (((int)x.b - y.b)); + // https://github.com/mapnik/mapnik/issues/1087 + if (x.a != y.a) return x.a < y.a; + if (x.r != y.r) return x.r < y.r; + if (x.g != y.g) return x.g < y.g; + return x.b < y.b; } std::size_t rgba::hash_func::operator()(rgba const& p) const