Re: svn commit: r591583 - in /xmlgraphics/fop/trunk/src: codegen/fonts/ java/org/apache/fop/fonts/ java/org/apache/fop/pdf/
Hi Jeremias, Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/Typeface.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/Typeface.java?rev=591583r1=591582r2=591583view=diff == --- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/Typeface.java (original) +++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/Typeface.java Sat Nov 3 03:51:31 2007 @@ -27,6 +27,8 @@ */ public abstract class Typeface implements FontMetrics { +private long charMapOps = 0; + /** * Get the encoding of the font. * @return the encoding @@ -39,6 +41,23 @@ * @return the mapped character */ public abstract char mapChar(char c); + +/** + * Used for keeping track of character mapping operations in order to determine if a font + * was used at all or not. + */ +protected void notifyMapOperation() { +this.charMapOps++; +} + +/** + * Indicates whether this font had to do any character mapping operations. If that was + * not the case, it's an indication that the font has never actually been used. + * @return true if the font had to do any character mapping operations + */ +public boolean hadMappingOperations() { +return (this.charMapOps 0); +} Basically you need to know whether the font has been used or not. Then why not just use a boolean for charMapOps? Vincent
Re: svn commit: r591583 - in /xmlgraphics/fop/trunk/src: codegen/fonts/ java/org/apache/fop/fonts/ java/org/apache/fop/pdf/
Statistical interest. Increasing a long shouldn't use many more CPU cycles than setting a boolean to true, right? Jeremias Maerki On 05.11.2007 11:32:09 Vincent Hennebert wrote: Hi Jeremias, Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/Typeface.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/Typeface.java?rev=591583r1=591582r2=591583view=diff == --- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/Typeface.java (original) +++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/Typeface.java Sat Nov 3 03:51:31 2007 @@ -27,6 +27,8 @@ */ public abstract class Typeface implements FontMetrics { +private long charMapOps = 0; + /** * Get the encoding of the font. * @return the encoding @@ -39,6 +41,23 @@ * @return the mapped character */ public abstract char mapChar(char c); + +/** + * Used for keeping track of character mapping operations in order to determine if a font + * was used at all or not. + */ +protected void notifyMapOperation() { +this.charMapOps++; +} + +/** + * Indicates whether this font had to do any character mapping operations. If that was + * not the case, it's an indication that the font has never actually been used. + * @return true if the font had to do any character mapping operations + */ +public boolean hadMappingOperations() { +return (this.charMapOps 0); +} Basically you need to know whether the font has been used or not. Then why not just use a boolean for charMapOps? Vincent
Re: svn commit: r591583 - in /xmlgraphics/fop/trunk/src: codegen/fonts/ java/org/apache/fop/fonts/ java/org/apache/fop/pdf/
Jeremias Maerki wrote: Statistical interest. Increasing a long shouldn't use many more CPU cycles than setting a boolean to true, right? That’s not a problem of performance. When I see this I simply wonder why a long is used while a boolean would be sufficient. Statistical interest, why not, although here it only exists when doing a manual debugging session. That’s not a very big deal anyway since here the class is small, but when you encounter such variables in hundreds of other lines of codes, believe me, it takes a while before figuring out that they are actually used as booleans... A small comment, perhaps? Vincent
Re: svn commit: r591583 - in /xmlgraphics/fop/trunk/src: codegen/fonts/ java/org/apache/fop/fonts/ java/org/apache/fop/pdf/
On Nov 5, 2007, at 12:42, Vincent Hennebert wrote: Jeremias Maerki wrote: Statistical interest. Increasing a long shouldn't use many more CPU cycles than setting a boolean to true, right? That’s not a problem of performance. When I see this I simply wonder why a long is used while a boolean would be sufficient. Statistical interest, why not, although here it only exists when doing a manual debugging session. That’s not a very big deal anyway since here the class is small, but when you encounter such variables in hundreds of other lines of codes, believe me, it takes a while before figuring out that they are actually used as booleans... True, or should I say 'one' :-) Funny, this description somehow reminds me of the times when I familiarized myself with the good old Win32 API... ;-) Cheers Andreas