shithub: neatroff

Download patch

ref: 5c346ca397e873342f74115ead3c340df28be62a
parent: 4d4dea5a36a677716b56d800e86f4ba4df60327b
author: Ali Gholami Rudi <[email protected]>
date: Tue Jun 11 12:29:45 EDT 2013

font: call strcmp() less frequently in font_find()

font_find() is now neatroff's main bottleneck.  This should
make it less so for now.  I may introduce a hash table or
change it to use binary search in future.

--- a/font.c
+++ b/font.c
@@ -15,7 +15,7 @@
 {
 	int i;
 	for (i = 0; i < fn->n; i++)
-		if (!strcmp(name, fn->c[i]))
+		if (name[0] == fn->c[i][0] && !strcmp(name, fn->c[i]))
 			return fn->g[i];
 	return NULL;
 }