Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.
C++
Use std::accumulate for calculating the bounds of shapes and nodes
Dmitry Kazakov69daaa65ab7c
diff --git a/libs/flake/KoShape.cpp b/libs/flake/KoShape.cppindex fa54b747f2..15abc6cabd 100644--- a/libs/flake/KoShape.cpp+++ b/libs/flake/KoShape.cpp@@ -10,6 +10,7 @@#include <limits>+#include "KisMpl.h"#include "KoShape.h"#include "KoShape_p.h"#include "KoShapeContainer.h"@@ -311,11 +312,8 @@ QRectF KoShape::boundingRect() constQRectF KoShape::boundingRect(const QList<KoShape *> &shapes){- QRectF boundingRect;- Q_FOREACH (KoShape *shape, shapes) {- boundingRect |= shape->boundingRect();- }- return boundingRect;+ return std::accumulate(shapes.begin(), shapes.end(), QRectF(),+ kismpl::mem_bit_or(&KoShape::boundingRect));}QRectF KoShape::absoluteOutlineRect() const@@ -325,11 +323,8 @@ QRectF KoShape::absoluteOutlineRect() constQRectF KoShape::absoluteOutlineRect(const QList<KoShape *> &shapes){- QRectF absoluteOutlineRect;- Q_FOREACH (KoShape *shape, shapes) {- absoluteOutlineRect |= shape->absoluteOutlineRect();- }- return absoluteOutlineRect;+ return std::accumulate(shapes.begin(), shapes.end(), QRectF(),+ kismpl::mem_bit_or(&KoShape::absoluteOutlineRect));}QTransform KoShape::absoluteTransformation() constdiff --git a/libs/ui/kis_clipboard.cc b/libs/ui/kis_clipboard.ccindex eb13b478d8..4a699ec0ad 100644--- a/libs/ui/kis_clipboard.cc+++ b/libs/ui/kis_clipboard.cc@@ -327,10 +327,9 @@ KisPaintDeviceSP KisClipboard::clipFromKritaLayers(const KoColorSpace *cs) constif (nodes.size() > 1) {// we explicitly include point (0,0) into the bounds since that// is a requirement for the image- QRect bounds = QRect(0, 0, 1, 1);- Q_FOREACH (KisNodeSP node, nodes) {- bounds |= node->exactBounds();- }+ const QRect bounds =+ std::accumulate(nodes.begin(), nodes.end(), QRect(0, 0, 1, 1),+ kismpl::mem_bit_or(&KisNode::exactBounds));// if no color space provided choose the most used one in the layer dataif (cs == nullptr) {