Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 30 Nov 2009 18:48:07 +0000 (UTC)
From:      Ed Schouten <ed@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r199971 - user/ed/newcons/sys/dev/vt
Message-ID:  <200911301848.nAUIm77V037655@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ed
Date: Mon Nov 30 18:48:07 2009
New Revision: 199971
URL: http://svn.freebsd.org/changeset/base/199971

Log:
  Optimize vtfont_bisearch() for the common case (ASCII).
  
  More than 90% of the time we'll probably just display ASCII characters.
  In almost all cases this is stored in entry 0 of the map, so validate
  the first map by hand.

Modified:
  user/ed/newcons/sys/dev/vt/vt_font.c

Modified: user/ed/newcons/sys/dev/vt/vt_font.c
==============================================================================
--- user/ed/newcons/sys/dev/vt/vt_font.c	Mon Nov 30 18:26:46 2009	(r199970)
+++ user/ed/newcons/sys/dev/vt/vt_font.c	Mon Nov 30 18:48:07 2009	(r199971)
@@ -53,10 +53,20 @@ vtfont_bisearch(const struct vt_font_map
 	min = 0;
 	max = len - 1;
 
-	if (len == 0 || src < map[0].vfm_src ||
-	    src > map[max].vfm_src + map[max].vfm_len)
+	/* Empty font map. */
+	if (len == 0)
+		return (0);
+	/* Character below minimal entry. */
+	if (src < map[0].vfm_src)
+		return (0);
+	/* Optimization: ASCII characters occur very often. */
+	if (src <= map[0].vfm_src + map[0].vfm_len)
+		return (src - map[0].vfm_src + map[0].vfm_dst);
+	/* Character above maximum entry. */
+	if (src > map[max].vfm_src + map[max].vfm_len)
 		return (0);
 
+	/* Binary search. */
 	while (max >= min) {
 		mid = (min + max) / 2;
 		if (src < map[mid].vfm_src)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200911301848.nAUIm77V037655>