Mir

Code review comment for lp:~vanvugt/mir/Rectangle-contains-Rectangle

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

22 + return r.top_left.x >= top_left.x &&
23 + r.top_left.x.as_int() + r.size.width.as_int() <=
24 + top_left.x.as_int() + size.width.as_int() &&
25 + r.top_left.y >= top_left.y &&
26 + r.top_left.y.as_int() + r.size.height.as_int() <=
27 + top_left.y.as_int() + size.height.as_int();

I do find this a bit hard to parse. I'd write something like:

    auto const btmright = bottom_right();
    auto const r_btmright = r.bottom_right();

    return r.top_left.x >= top_left.x && r.top_left.y >= top_left.y &&
           r_btmright.x <= btmright.x && r_btmright.y <= btmright.y;

review: Approve

« Back to merge proposal