[PATCH:libX11 3/7] XDefaultOMIF: additional code simplification

Alan Coopersmith alan.coopersmith at oracle.com
Fri Jan 1 18:14:58 PST 2016


Don't need to test for a case that we already returned for, don't need
to store a count that will only ever be 1 if we didn't return, don't
need to increment pointers to allow storing more than one item when we
can only ever possibly do one.

Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 src/xlibi18n/XDefaultOMIF.c | 43 +++++++++++--------------------------------
 1 file changed, 11 insertions(+), 32 deletions(-)

diff --git a/src/xlibi18n/XDefaultOMIF.c b/src/xlibi18n/XDefaultOMIF.c
index 0e17204..851e169 100644
--- a/src/xlibi18n/XDefaultOMIF.c
+++ b/src/xlibi18n/XDefaultOMIF.c
@@ -237,15 +237,10 @@ init_core_part(
     FontSet font_set;
     XFontStruct **font_struct_list;
     char **font_name_list, *font_name_buf;
-    int	count;
 
     font_set = gen->font_set;
-    count = 0;
 
-    if (font_set->font_name != NULL) {
-	count++;
-    }
-    if (count == 0)
+    if (font_set->font_name == NULL)
         return False;
 
     font_struct_list = Xmalloc(sizeof(XFontStruct *));
@@ -264,18 +259,13 @@ init_core_part(
     oc->core.font_info.font_name_list = font_name_list;
     oc->core.font_info.font_struct_list = font_struct_list;
 
-    font_set = gen->font_set;
-
-    if (font_set->font_name != NULL) {
-	font_set->id = 1;
-	if (font_set->font)
-	    *font_struct_list++ = font_set->font;
-	else
-	    *font_struct_list++ = font_set->info;
-	Xfree(font_set->font_name);
-	*font_name_list++ = font_set->font_name = font_name_buf;
-	font_name_buf += strlen(font_name_buf) + 1;
-    }
+    font_set->id = 1;
+    if (font_set->font)
+        *font_struct_list = font_set->font;
+    else
+        *font_struct_list = font_set->info;
+    Xfree(font_set->font_name);
+    *font_name_list = font_set->font_name = font_name_buf;
 
     set_fontset_extents(oc);
 
@@ -480,16 +470,10 @@ set_missing_list(
     XOCGenericPart *gen = XOC_GENERIC(oc);
     FontSet font_set;
     char **charset_list, *charset_buf;
-    int	count;
 
     font_set = gen->font_set;
-    count = 0;
-
-    if (!font_set->info && !font_set->font) {
-	count++;
-    }
 
-    if (count == 0)
+    if (font_set->info == NULL || font_set->font == NULL)
 	return True;
 
     charset_list = Xmalloc(sizeof(char *));
@@ -504,12 +488,8 @@ set_missing_list(
 
     oc->core.missing_list.charset_list = charset_list;
 
-    font_set = gen->font_set;
+    *charset_list = charset_buf;
 
-    if (!font_set->info && !font_set->font) {
-	*charset_list++ = charset_buf;
-	charset_buf += strlen(charset_buf) + 1;
-    }
     return True;
 }
 
@@ -1090,8 +1070,7 @@ init_om(
 
     data = gen->data;
 
-    *required_list++ = bufptr;
-    bufptr += strlen(bufptr) + 1;
+    *required_list = bufptr;
 
     /* orientation list */
     orientation = Xmalloc(sizeof(XOrientation));
-- 
2.6.1



More information about the xorg-devel mailing list