diff options
| author | Werner LEMBERG <wl@gnu.org> | 2010-12-20 06:39:01 +0000 |
|---|---|---|
| committer | Werner LEMBERG <wl@gnu.org> | 2010-12-20 06:39:01 +0000 |
| commit | a9269fd43bcd7e9757f80af84e95a50fcd974585 (patch) | |
| tree | f58828d2ec886b82dab5c8a074f3662effae87e0 /src/roff/troff/input.cpp | |
| parent | 9a08b71d07ede8540d98236b1c80dee3147fba9a (diff) | |
| download | groff-git-a9269fd43bcd7e9757f80af84e95a50fcd974585.tar.gz | |
Speed up access to cflags values.
We now recompute the cflags values for all charinfo objects if
`.class' has been called.
* src/roff/troff/charinfo.h: Add external references to `class_flag'
and `get_flags'.
(charinfo): `get_flags' no longer has a return value.
(charinfo::overlaps_horizontally, charinfo::overlaps_vertically,
charinfo::can_break_before, charinfo::can_break_after,
charinfo::can_break_after, charinfo::ends_sentence,
charinfo::transparent,, charinfo:ignore_hcodes,
charinfo::prohibit_break_before, charinfo::prohibit_break_after,
charinfo::inter_char_space): Call global `get_flags' only if
necessary.
(charinfo::add_to_class): Set `class_flag'.
* src/roff/troff/input.cpp (class_flag): New global flag.
(charinfo::charinfo): Call `get_flags' member function.
(get_flags): New global function which iterates over all entries in
the charinfo dictionary.
(charinfo::get_flags): Set `flags' directly.
Diffstat (limited to 'src/roff/troff/input.cpp')
| -rw-r--r-- | src/roff/troff/input.cpp | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp index b6e73ed75..7a0f46cea 100644 --- a/src/roff/troff/input.cpp +++ b/src/roff/troff/input.cpp @@ -83,6 +83,7 @@ void transparent_file(); token tok; int break_flag = 0; +int class_flag = 0; int color_flag = 1; // colors are on by default static int backtrace_flag = 0; #ifndef POPEN_MISSING @@ -8477,6 +8478,7 @@ charinfo::charinfo(symbol s) { index = next_index++; number = -1; + get_flags(); } int charinfo::get_unicode_code() @@ -8507,25 +8509,36 @@ void charinfo::set_translation(charinfo *ci, int tt, int ti) transparent_translate = tt; } +// Recompute flags for all entries in the charinfo dictionary. +void get_flags() +{ + dictionary_iterator iter(charinfo_dictionary); + charinfo *ci; + symbol s; + while (iter.get(&s, (void **)&ci)) { + assert(!s.is_null()); + ci->get_flags(); + } + class_flag = 0; +} + // Get the union of all flags affecting this charinfo. -unsigned int charinfo::get_flags() +void charinfo::get_flags() { - unsigned int all_flags = flags; dictionary_iterator iter(char_class_dictionary); - charinfo *cp; + charinfo *ci; symbol s; - while (iter.get(&s, (void **)&cp)) { + while (iter.get(&s, (void **)&ci)) { assert(!s.is_null()); - if (cp->contains(get_unicode_code())) { + if (ci->contains(get_unicode_code())) { #if defined(DEBUGGING) if (debug_state) fprintf(stderr, "charinfo::get_flags %p %s %d\n", - (void *)cp, cp->nm.contents(), cp->flags); + (void *)ci, ci->nm.contents(), ci->flags); #endif - all_flags |= cp->flags; + flags |= ci->flags; } } - return all_flags; } void charinfo::set_special_translation(int c, int tt) |
