[hackers] [st] Simplify selected(). || noname

From: <git_AT_suckless.org>
Date: Tue, 29 Apr 2014 10:05:30 +0200

commit 5f91983541014d34274087dbf723b48551f90fc0
Author: noname <noname_AT_inventati.org>
Date: Sun Apr 27 15:16:41 2014 +0400

    Simplify selected().

diff --git a/st.c b/st.c
index 672c47a..5198749 100644
--- a/st.c
+++ b/st.c
_AT_@ -674,18 +674,13 @@ selsort(void) {
 
 static inline bool
 selected(int x, int y) {
- if(sel.ne.y == y && sel.nb.y == y)
- return BETWEEN(x, sel.nb.x, sel.ne.x);
+ if(sel.type == SEL_RECTANGULAR)
+ return BETWEEN(y, sel.nb.y, sel.ne.y)
+ && BETWEEN(x, sel.nb.x, sel.ne.x);
 
- if(sel.type == SEL_RECTANGULAR) {
- return ((sel.nb.y <= y && y <= sel.ne.y)
- && (sel.nb.x <= x && x <= sel.ne.x));
- }
-
- return ((sel.nb.y < y && y < sel.ne.y)
- || (y == sel.ne.y && x <= sel.ne.x))
- || (y == sel.nb.y && x >= sel.nb.x
- && (x <= sel.ne.x || sel.nb.y != sel.ne.y));
+ return BETWEEN(y, sel.nb.y, sel.ne.y)
+ && (y != sel.nb.y || x >= sel.nb.x)
+ && (y != sel.ne.y || x <= sel.ne.x);
 }
 
 void
Received on Tue Apr 29 2014 - 10:05:30 CEST

This archive was generated by hypermail 2.3.0 : Tue Apr 29 2014 - 10:12:09 CEST