summaryrefslogtreecommitdiff
path: root/sys/include/draw.h
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2016-04-13 00:34:48 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2016-04-13 00:34:48 +0200
commit1787584ad839002584e0752e4df41b6f3b70064b (patch)
tree41ece61d6df4396e1298247a8cc2f2661e174ab1 /sys/include/draw.h
parent6b989beb2f870c46363c1feba1a25c59add41d5a (diff)
libdraw: avoid BPSHORT()/BPLONG() expansion, cleanup loadchar(),cachechars()
assigning the expression value to a temporary variable in BPSHORT() and BPLONG() saves arround 2K of text in rio on arm and arround 1K on amd64. loadchar(): use the passed in "h" as the char index instead of recomputing it from c-f->cache. dont recompute wid. cachechars(): do cache lookup and find oldest entry in a single loop pass.
Diffstat (limited to 'sys/include/draw.h')
-rw-r--r--sys/include/draw.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/sys/include/draw.h b/sys/include/draw.h
index 5c4f9608a..c6b62d4b7 100644
--- a/sys/include/draw.h
+++ b/sys/include/draw.h
@@ -505,10 +505,10 @@ extern int _cursorfd;
extern int _drawdebug; /* set to 1 to see errors from flushimage */
extern void _setdrawop(Display*, Drawop);
-#define BGSHORT(p) (((p)[0]<<0) | ((p)[1]<<8))
-#define BGLONG(p) ((BGSHORT(p)<<0) | (BGSHORT(p+2)<<16))
-#define BPSHORT(p, v) ((p)[0]=(v), (p)[1]=((v)>>8))
-#define BPLONG(p, v) (BPSHORT(p, (v)), BPSHORT(p+2, (v)>>16))
+#define BGSHORT(p) ((p)[0]|((p)[1]<<8))
+#define BGLONG(p) ((p)[0]|((p)[1]<<8)|((p)[2]<<16)|((p)[3]<<24))
+#define BPSHORT(p,v) do{ushort _v_=(v);(p)[0]=_v_;(p)[1]=_v_>>8;}while(0)
+#define BPLONG(p,v) do{ulong _v_=(v);(p)[0]=_v_;(p)[1]=_v_>>8;(p)[2]=_v_>>16;(p)[3]=_v_>>24;}while(0)
/*
* Compressed image file parameters and helper routines