Changed some parameters to be passed through const reference [A change suggested by Christian Packmann]. This gives a nice speed boost.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8628 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
|
||||
// Returns the union of the given rects.
|
||||
static inline clipping_rect
|
||||
union_rect(clipping_rect r1, clipping_rect r2)
|
||||
union_rect(const clipping_rect &r1, const clipping_rect &r2)
|
||||
{
|
||||
clipping_rect rect;
|
||||
|
||||
@@ -32,7 +32,7 @@ union_rect(clipping_rect r1, clipping_rect r2)
|
||||
// The caller should check if the returned rect is valid. If it isn't valid,
|
||||
// then the two rectangles don't intersect.
|
||||
static inline clipping_rect
|
||||
sect_rect(clipping_rect r1, clipping_rect r2)
|
||||
sect_rect(const clipping_rect &r1, const clipping_rect &r2)
|
||||
{
|
||||
clipping_rect rect;
|
||||
|
||||
@@ -58,7 +58,7 @@ offset_rect(clipping_rect &rect, int32 x, int32 y)
|
||||
|
||||
// Converts the given clipping_rect to a BRect
|
||||
static inline BRect
|
||||
to_BRect(clipping_rect rect)
|
||||
to_BRect(const clipping_rect &rect)
|
||||
{
|
||||
return BRect((float)rect.left, (float)rect.top, (float)rect.right, (float)rect.bottom);
|
||||
}
|
||||
@@ -66,7 +66,7 @@ to_BRect(clipping_rect rect)
|
||||
|
||||
// Converts the given BRect to a clipping_rect.
|
||||
static inline clipping_rect
|
||||
to_clipping_rect(BRect rect)
|
||||
to_clipping_rect(const BRect &rect)
|
||||
{
|
||||
clipping_rect clipRect;
|
||||
|
||||
@@ -81,7 +81,7 @@ to_clipping_rect(BRect rect)
|
||||
|
||||
// Checks if the given point lies in the given rect's area
|
||||
static inline bool
|
||||
point_in(clipping_rect rect, int32 px, int32 py)
|
||||
point_in(const clipping_rect &rect, int32 px, int32 py)
|
||||
{
|
||||
if (px >= rect.left && px <= rect.right
|
||||
&& py >= rect.top && py <= rect.bottom)
|
||||
@@ -92,7 +92,7 @@ point_in(clipping_rect rect, int32 px, int32 py)
|
||||
|
||||
// Same as above, but it accepts a BPoint parameter
|
||||
static inline bool
|
||||
point_in(clipping_rect rect, BPoint pt)
|
||||
point_in(const clipping_rect &rect, const BPoint &pt)
|
||||
{
|
||||
if (pt.x >= rect.left && pt.x <= rect.right
|
||||
&& pt.y >= rect.top && pt.y <= rect.bottom)
|
||||
@@ -103,7 +103,7 @@ point_in(clipping_rect rect, BPoint pt)
|
||||
|
||||
// Checks if the rect is valid
|
||||
static inline bool
|
||||
valid_rect(clipping_rect rect)
|
||||
valid_rect(const clipping_rect &rect)
|
||||
{
|
||||
if (rect.left <= rect.right && rect.top <= rect.bottom)
|
||||
return true;
|
||||
@@ -113,10 +113,10 @@ valid_rect(clipping_rect rect)
|
||||
|
||||
// Checks if the two rects intersect.
|
||||
static inline bool
|
||||
rects_intersect(clipping_rect rectA, clipping_rect rectB)
|
||||
rects_intersect(const clipping_rect &rectA, const clipping_rect &rectB)
|
||||
{
|
||||
// We behave like BRect::Intersects() does:
|
||||
// we return false if one of the two rects is not valid
|
||||
// TODO: should we skip that check and let the caller do this
|
||||
// kind of work ?
|
||||
if (!valid_rect(rectA) || !valid_rect(rectB))
|
||||
return false;
|
||||
|
||||
@@ -131,7 +131,7 @@ rects_intersect(clipping_rect rectA, clipping_rect rectB)
|
||||
|
||||
// Returns the width of the given rect.
|
||||
static inline int32
|
||||
rect_width(clipping_rect rect)
|
||||
rect_width(const clipping_rect &rect)
|
||||
{
|
||||
return rect.right - rect.left;
|
||||
}
|
||||
@@ -139,7 +139,7 @@ rect_width(clipping_rect rect)
|
||||
|
||||
// Returns the height of the given rect.
|
||||
static inline int32
|
||||
rect_height(clipping_rect rect)
|
||||
rect_height(const clipping_rect &rect)
|
||||
{
|
||||
return rect.bottom - rect.top;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user