This patch does not change the logic of the function. It simply trades
two levels of if statement nestings for a goto.

Signed-off-by: Silvan Jegen <[email protected]>
---

I find this version of the loop to be easier to follow. Combined with
the reduced line count I think this patch is worth applying.

 st.c | 34 +++++++++++++++-------------------
 1 file changed, 15 insertions(+), 19 deletions(-)

diff --git a/st.c b/st.c
index fde4d2d..4418b97 100644
--- a/st.c
+++ b/st.c
@@ -3249,28 +3249,24 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, 
int bytelen) {
                        bytelen -= u8cblen;
 
                        doesexist = XftCharExists(xw.dpy, font->match, 
unicodep);
-                       if(oneatatime || !doesexist || bytelen <= 0) {
-                               if(oneatatime || bytelen <= 0) {
-                                       if(doesexist) {
-                                               u8fl++;
-                                               u8fblen += u8cblen;
-                                       }
-                               }
-
-                               if(u8fl > 0) {
-                                       XftDrawStringUtf8(xw.draw, fg,
-                                                       font->match, xp,
-                                                       winy + font->ascent,
-                                                       (FcChar8 *)u8fs,
-                                                       u8fblen);
-                                       xp += xw.cw * u8fl;
-
-                               }
-                               break;
-                       }
+                       if(!doesexist)
+                           goto justdraw;
 
                        u8fl++;
                        u8fblen += u8cblen;
+
+                       if(!oneatatime && bytelen > 0)
+                           continue;
+justdraw:
+                       if(u8fl > 0) {
+                               XftDrawStringUtf8(xw.draw, fg,
+                                               font->match, xp,
+                                               winy + font->ascent,
+                                               (FcChar8 *)u8fs,
+                                               u8fblen);
+                               xp += xw.cw * u8fl;
+                       }
+                       break;
                }
                if(doesexist) {
                        if(oneatatime)
-- 
2.0.0


Reply via email to