From 7817d68b5402511a42421b9ed0c5ce9f4c41203f Mon Sep 17 00:00:00 2001 From: Ilya Shipitsin Date: Sun, 23 Sep 2018 03:57:34 +0500 Subject: [PATCH] simplify boolean expression, found by PVS analyzer (#1318) Magick++/lib/Color.cpp 303 warn V728 An excessive check can be simplified. The '(A && B) || (!A && !B)' expression is equivalent to the 'bool(A) == bool(B)' expression. Magick++/lib/Image.cpp 314 warn V728 An excessive check can be simplified. The '(A && !B) || (!A && B)' expression is equivalent to the 'bool(A) != bool(B)' expression. --- Magick++/lib/Color.cpp | 2 +- Magick++/lib/Image.cpp | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Magick++/lib/Color.cpp b/Magick++/lib/Color.cpp index f8de206ee..4f1611bde 100644 --- a/Magick++/lib/Color.cpp +++ b/Magick++/lib/Color.cpp @@ -300,7 +300,7 @@ Magick::Color::PixelType Magick::Color::pixelType() const void Magick::Color::isValid(bool valid_) { - if ((valid_ && isValid()) || (!valid_ && !isValid())) + if (bool(valid_) == bool(isValid())) return; if (!_pixelOwn) diff --git a/Magick++/lib/Image.cpp b/Magick++/lib/Image.cpp index ec1688490..a6dfcf0f3 100644 --- a/Magick++/lib/Image.cpp +++ b/Magick++/lib/Image.cpp @@ -311,8 +311,7 @@ void Magick::Image::alpha(const bool alphaFlag_) // the image already has a matte channel but a matte channel is not // desired, then set the matte channel to opaque. GetPPException; - if ((alphaFlag_ && !constImage()->alpha_trait) || - (constImage()->alpha_trait && !alphaFlag_)) + if (bool(alphaFlag_) != bool(constImage()->alpha_trait)) SetImageAlpha(image(),OpaqueAlpha,exceptionInfo); ThrowImageException; -- 2.40.0