Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Unified Diff: include/core/SkRect.h

Issue 695443005: Optimize SkRect::sort() (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: minor fix Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkRect.h
diff --git a/include/core/SkRect.h b/include/core/SkRect.h
index 96bf0f4d9088bf64e8c02dea5e5d625bc9752564..91765424c71643dd2544c10406d31e221552c4ed 100644
--- a/include/core/SkRect.h
+++ b/include/core/SkRect.h
@@ -843,15 +843,13 @@ public:
* other. When this returns, left <= right && top <= bottom
*/
void sort() {
- SkScalar min = SkMinScalar(fLeft, fRight);
- SkScalar max = SkMaxScalar(fLeft, fRight);
- fLeft = min;
- fRight = max;
-
- min = SkMinScalar(fTop, fBottom);
- max = SkMaxScalar(fTop, fBottom);
- fTop = min;
- fBottom = max;
+ if (fLeft > fRight) {
+ SkTSwap<SkScalar>(fLeft, fRight);
+ }
+
+ if (fTop > fBottom) {
+ SkTSwap<SkScalar>(fTop, fBottom);
+ }
}
/**
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698