From 1e2ac9c2eef012a3e77133817803878bacfa91b8 Mon Sep 17 00:00:00 2001 From: tupshin Date: Wed, 10 Mar 2004 01:16:04 +0000 Subject: [PATCH] two Hash font optimization This patch makes a huge difference in startup performance. Scenario: A simple app that contains 240 boxes each with text foo. Measurement: time from launch until core stops using 100% CPU normal Font.java: 61 seconds this Font.java: 7 seconds darcs-hash:20040310011604-a9258-ae21b540fe7add307aa7cf8ef82f8a3a1521fd06.gz --- src/org/ibex/Font.java | 108 ++++++++++++++++++++++++++++-------------------- 1 file changed, 63 insertions(+), 45 deletions(-) diff --git a/src/org/ibex/Font.java b/src/org/ibex/Font.java index ea17dff..48fd0de 100644 --- a/src/org/ibex/Font.java +++ b/src/org/ibex/Font.java @@ -3,6 +3,8 @@ package org.ibex; import org.ibex.translators.*; import org.ibex.util.*; import java.io.*; +import java.util.Hashtable; + import org.ibex.js.JSExn; // FEATURE: this could be cleaner @@ -36,7 +38,8 @@ public class Font { // Statics ////////////////////////////////////////////////////////////////////// private static final Freetype freetype = new Freetype(); - static final Queue glyphsToBeRendered = new Queue(255); + static final Hashtable glyphsToBeCached = new Hashtable(); + static final Hashtable glyphsToBeDisplayed = new Hashtable(); private static Cache fontCache = new Cache(100); public static Font getFont(Stream stream, int pointsize) { Font ret = (Font)fontCache.get(stream, new Integer(pointsize)); @@ -62,48 +65,51 @@ public class Font { final Scheduler.Task callback) { boolean encounteredUnrenderedGlyph = false; int width = 0, height = 0; - for(int i=0; i