Optimize SkRect::sort()
This optimization can reduce comparison and assignments. For geo_rect_sort benchmark, performance improved to 1.63us from 3.28us. BUG=skia: Review URL: https://codereview.chromium.org/695443005
This commit is contained in:
parent
87a94eb163
commit
fb502f072f
@ -843,15 +843,13 @@ public:
|
|||||||
* other. When this returns, left <= right && top <= bottom
|
* other. When this returns, left <= right && top <= bottom
|
||||||
*/
|
*/
|
||||||
void sort() {
|
void sort() {
|
||||||
SkScalar min = SkMinScalar(fLeft, fRight);
|
if (fLeft > fRight) {
|
||||||
SkScalar max = SkMaxScalar(fLeft, fRight);
|
SkTSwap<SkScalar>(fLeft, fRight);
|
||||||
fLeft = min;
|
}
|
||||||
fRight = max;
|
|
||||||
|
if (fTop > fBottom) {
|
||||||
min = SkMinScalar(fTop, fBottom);
|
SkTSwap<SkScalar>(fTop, fBottom);
|
||||||
max = SkMaxScalar(fTop, fBottom);
|
}
|
||||||
fTop = min;
|
|
||||||
fBottom = max;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user