groff-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Groff-commit] groff ChangeLog src/roff/troff/charinfo.h src/r...


From: Werner LEMBERG
Subject: [Groff-commit] groff ChangeLog src/roff/troff/charinfo.h src/r...
Date: Mon, 20 Dec 2010 06:39:01 +0000

CVSROOT:        /cvsroot/groff
Module name:    groff
Changes by:     Werner LEMBERG <wl>     10/12/20 06:39:01

Modified files:
        .              : ChangeLog 
        src/roff/troff : charinfo.h input.cpp 

Log message:
        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.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/groff/ChangeLog?cvsroot=groff&r1=1.1260&r2=1.1261
http://cvs.savannah.gnu.org/viewcvs/groff/src/roff/troff/charinfo.h?cvsroot=groff&r1=1.19&r2=1.20
http://cvs.savannah.gnu.org/viewcvs/groff/src/roff/troff/input.cpp?cvsroot=groff&r1=1.67&r2=1.68

Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/groff/groff/ChangeLog,v
retrieving revision 1.1260
retrieving revision 1.1261
diff -u -b -r1.1260 -r1.1261
--- ChangeLog   19 Dec 2010 20:47:38 -0000      1.1260
+++ ChangeLog   20 Dec 2010 06:39:01 -0000      1.1261
@@ -1,3 +1,28 @@
+2010-12-20  Werner LEMBERG  <address@hidden>
+
+       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.
+
 2010-12-19  Werner LEMBERG  <address@hidden>
 
        Protect `.class' against cyclic nesting.

Index: src/roff/troff/charinfo.h
===================================================================
RCS file: /cvsroot/groff/groff/src/roff/troff/charinfo.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- src/roff/troff/charinfo.h   19 Dec 2010 20:47:38 -0000      1.19
+++ src/roff/troff/charinfo.h   20 Dec 2010 06:39:01 -0000      1.20
@@ -21,6 +21,9 @@
 #include <vector>
 #include <utility>
 
+extern int class_flag; // set if there was a call to `.class'
+extern void get_flags();
+
 class macro;
 
 class charinfo : glyph {
@@ -86,7 +89,7 @@
   int get_translation_input();
   charinfo *get_translation(int = 0);
   void set_translation(charinfo *, int, int);
-  unsigned int get_flags();
+  void get_flags();
   void set_flags(unsigned int);
   void set_special_translation(int, int);
   int get_special_translation(int = 0);
@@ -116,52 +119,72 @@
 
 inline int charinfo::overlaps_horizontally()
 {
-  return get_flags() & OVERLAPS_HORIZONTALLY;
+  if (class_flag)
+    ::get_flags();
+  return flags & OVERLAPS_HORIZONTALLY;
 }
 
 inline int charinfo::overlaps_vertically()
 {
-  return get_flags() & OVERLAPS_VERTICALLY;
+  if (class_flag)
+    ::get_flags();
+  return flags & OVERLAPS_VERTICALLY;
 }
 
 inline int charinfo::can_break_before()
 {
-  return get_flags() & BREAK_BEFORE;
+  if (class_flag)
+    ::get_flags();
+  return flags & BREAK_BEFORE;
 }
 
 inline int charinfo::can_break_after()
 {
-  return get_flags() & BREAK_AFTER;
+  if (class_flag)
+    ::get_flags();
+  return flags & BREAK_AFTER;
 }
 
 inline int charinfo::ends_sentence()
 {
-  return get_flags() & ENDS_SENTENCE;
+  if (class_flag)
+    ::get_flags();
+  return flags & ENDS_SENTENCE;
 }
 
 inline int charinfo::transparent()
 {
-  return get_flags() & TRANSPARENT;
+  if (class_flag)
+    ::get_flags();
+  return flags & TRANSPARENT;
 }
 
 inline int charinfo::ignore_hcodes()
 {
-  return get_flags() & IGNORE_HCODES;
+  if (class_flag)
+    ::get_flags();
+  return flags & IGNORE_HCODES;
 }
 
 inline int charinfo::prohibit_break_before()
 {
-  return get_flags() & DONT_BREAK_BEFORE;
+  if (class_flag)
+    ::get_flags();
+  return flags & DONT_BREAK_BEFORE;
 }
 
 inline int charinfo::prohibit_break_after()
 {
-  return get_flags() & DONT_BREAK_AFTER;
+  if (class_flag)
+    ::get_flags();
+  return flags & DONT_BREAK_AFTER;
 }
 
 inline int charinfo::inter_char_space()
 {
-  return get_flags() & INTER_CHAR_SPACE;
+  if (class_flag)
+    ::get_flags();
+  return flags & INTER_CHAR_SPACE;
 }
 
 inline int charinfo::numbered()
@@ -255,6 +278,7 @@
 
 inline void charinfo::add_to_class(int c)
 {
+  class_flag = 1;
   // TODO ranges cumbersome for single characters?
   ranges.push_back(std::pair<int, int>(c, c));
 }
@@ -262,11 +286,13 @@
 inline void charinfo::add_to_class(int lo,
                                   int hi)
 {
+  class_flag = 1;
   ranges.push_back(std::pair<int, int>(lo, hi));
 }
 
 inline void charinfo::add_to_class(charinfo *ci)
 {
+  class_flag = 1;
   nested_classes.push_back(ci);
 }
 

Index: src/roff/troff/input.cpp
===================================================================
RCS file: /cvsroot/groff/groff/src/roff/troff/input.cpp,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -b -r1.67 -r1.68
--- src/roff/troff/input.cpp    19 Dec 2010 20:47:38 -0000      1.67
+++ src/roff/troff/input.cpp    20 Dec 2010 06:39:01 -0000      1.68
@@ -83,6 +83,7 @@
 
 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 @@
 {
   index = next_index++;
   number = -1;
+  get_flags();
 }
 
 int charinfo::get_unicode_code()
@@ -8507,25 +8509,36 @@
   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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]