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
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user