diff src/fontcolor-msw.c @ 5350:94bbd4792049

Have #'sort*, #'merge use the same test approach as functions from cl-seq.el 2011-02-05 Aidan Kehoe <kehoea@parhasard.net> * fns.c: * fns.c (check_lss_key, check_lss_key_car): New. * fns.c (check_string_lessp_key check_string_lessp_key_car): New. * fns.c (get_merge_predicate): New. * fns.c (list_merge): * fns.c (array_merge): * fns.c (list_array_merge_into_list): * fns.c (list_list_merge_into_array): * fns.c (list_array_merge_into_array): * fns.c (Fmerge): * fns.c (list_sort): * fns.c (array_sort): * fns.c (FsortX): * fns.c (syms_of_fns): * lisp.h: Move #'sort, #'merge to using the same test approach as is used in the functions that take TEST, TEST-NOT and KEY arguments. This allows us to avoid the Ffuncall() overhead when the most common PREDICATE arguments are supplied, in particular #'< and #'string-lessp. * fontcolor-msw.c (sort_font_list_function): * fontcolor-msw.c (mswindows_enumerate_fonts): * dired.c: * dired.c (Fdirectory_files): * fileio.c: * fileio.c (build_annotations): * fileio.c (syms_of_fileio): * keymap.c: * keymap.c (keymap_submaps): * keymap.c (map_keymap_sort_predicate): * keymap.c (describe_map_sort_predicate): * keymap.c (describe_map): Change the various C predicates passed to list_sort () and list_merge () to fit the new calling convention, returning non-zero if the first argument is less than the second, zero otherwise.
author Aidan Kehoe <kehoea@parhasard.net>
date Sat, 05 Feb 2011 12:04:34 +0000
parents 6c8f5574d4a1
children 0af042a0c116
line wrap: on
line diff
--- a/src/fontcolor-msw.c	Sun Jan 30 14:27:31 2011 +0100
+++ b/src/fontcolor-msw.c	Sat Feb 05 12:04:34 2011 +0000
@@ -1198,10 +1198,9 @@
    "family::::charset" for TrueType fonts, "family::size::charset"
    otherwise. */
 
-static Lisp_Object
-sort_font_list_function (Lisp_Object obj1, Lisp_Object obj2,
-			 Lisp_Object UNUSED (pred),
-                         Lisp_Object UNUSED (key_function))
+static Boolint
+sort_font_list_function (Lisp_Object UNUSED (pred), Lisp_Object UNUSED (key),
+			 Lisp_Object obj1, Lisp_Object obj2)
 {
   Ibyte *font1, *font2;
   Ibyte *c1, *c2;
@@ -1215,16 +1214,16 @@
     5. Courier New over other families.
   */
 
-  /* The sort function should return non-nil if OBJ1 < OBJ2, nil otherwise.
-     NOTE: This is backwards from the way qsort() works. */
+  /* The sort function should return non-zero if OBJ1 < OBJ2, zero
+     otherwise. */
 
   t1 = !NILP (XCDR (obj1));
   t2 = !NILP (XCDR (obj2));
 
   if (t1 && !t2)
-    return Qt;
+    return 1;
   if (t2 && !t1)
-    return Qnil;
+    return 0;
 
   font1 = XSTRING_DATA (XCAR (obj1));
   font2 = XSTRING_DATA (XCAR (obj2));
@@ -1236,9 +1235,9 @@
   t2 = !qxestrcasecmp_ascii (c2 + 1, "western");
 
   if (t1 && !t2)
-    return Qt;
+    return 1;
   if (t2 && !t1)
-    return Qnil;
+    return 0;
 
   c1 -= 2;
   c2 -= 2;
@@ -1246,9 +1245,9 @@
   t2 = *c2 == ':';
 
   if (t1 && !t2)
-    return Qt;
+    return 1;
   if (t2 && !t1)
-    return Qnil;
+    return 0;
 
   if (!t1 && !t2)
     {
@@ -1261,25 +1260,25 @@
       t2 = qxeatoi (c2 + 1) - 10;
 
       if (abs (t1) < abs (t2))
-	return Qt;
+	return 1;
       else if (abs (t2) < abs (t1))
-	return Qnil;
+	return 0;
       else if (t1 < t2)
 	/* Prefer a smaller font over a larger one just as far away
 	   because the smaller one won't upset the total line height if it's
 	   just a few chars. */
-	return Qt;
+	return 1;
     }
 
   t1 = !qxestrncasecmp_ascii (font1, "courier new:", 12);
   t2 = !qxestrncasecmp_ascii (font2, "courier new:", 12);
 
   if (t1 && !t2)
-    return Qt;
+    return 1;
   if (t2 && !t1)
-    return Qnil;
+    return 0;
 
-  return Qnil;
+  return 0;
 }
 
 /*