From 60c33390a88b667f1fc2420a08be87c3fd2ba260 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Tue, 11 Sep 2007 17:46:25 +0200 Subject: [PATCH] optimize drawtext a little --- draw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/draw.c b/draw.c index 612fa237c..6c04daa5e 100644 --- a/draw.c +++ b/draw.c @@ -31,6 +31,8 @@ drawtext(Display *disp, const char *text, unsigned long col[ColLast]) /* shorten text if necessary */ while(len && (w = textnw(buf, len)) > dc.w - h) buf[--len] = 0; + if(w > dc.w) + return; /* too long */ if(len < olen) { if(len > 1) @@ -40,8 +42,6 @@ drawtext(Display *disp, const char *text, unsigned long col[ColLast]) if(len > 3) buf[len - 3] = '.'; } - if(w > dc.w) - return; /* too long */ XSetForeground(disp, dc.gc, col[ColFG]); if(dc.font.set) XmbDrawString(disp, dc.drawable, dc.font.set, dc.gc, x, y, buf, len);