> if there are a lot of character classes, the frequently used
> function `charinfo::get_flags' can get expensive. Any idea how to
> cache its return value? Essentially, it needs to be computed only
> once, but as soon as `.class' is called again, it has to be
> recomputed (again, only once)...
>
> Perhaps calling `.class' should simply trigger recomputation of all
> charinfos in the dictionary?
After some thinking, I believe we need something like that anyway:
Consider for example, this:
.class [foo] abc
.cflags 1 \C'[foo]'
.class [foo] abcd
The result will probably suprise you: `d' now also has cflags value 1!
If groff has to access the cflags value of a character, it does two
things:
1. Get the current character's cflags value (if any).
2. Check all classes whether the current character is part of a
class. If yes, use the cflags value of that class (and do an OR
operation with the already retrieved cflags value if necessary).
I'll now implement caching like this:
1. If `.class' is called, set a global flag `class_flag' to true.
2. If there is any access to cflags values, recompute them for all
entries in the `charinfo_dictionary' and set `class_flag' to
false.
BTW, profiling shows indeed that calling `get_flags' uses far too much
time.
Werner