Previous Index Next

Misc. topics OR Accordion

@::::::@   @::::::@
@:::::@  @@@@:::::@
@:::::@  @::::::::@
@:::::@  @::::::::@
@:::::@  @:::::::@@
@:::::@  @@@@@@@@  
Some figfonts use every char in their definition; this means that different characters may need to use different line endings. This is "@" from the font doh, if @ were used as the end of line character for this figchar the parser would croak; /o will not work for this. One would like to avoid compiling the regular expression that parses each line of a figchar, it matches leading and trailing whitespace, and the body of the figchar, thousands of times; every line in a minimal 112 figchar, 10 line per figchar figfont; ASCII + German. The solution is to use qr to compile the regular expression once per figchar, outside of the tight loop which matches each figchar. This gives a significant performance boost. As some of you may be aware I am not a fan of OO, however Text::FIGlet is an OO module. Parsing a font file is expensive, so it makes sense to avoid redoing it. A reasonable manner of doing this is to associate a font with an an object. Another would be to use a global lookup table. The latter has the disadvantage of requiring the addition of a method to unload the figfont, since they can consume a fair chunk of memory. With the former the user can simply destroy their object.