texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/XS/parsetexi/counter.c (counter_elem


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/XS/parsetexi/counter.c (counter_element_value): add.
Date: Sun, 29 Sep 2024 04:46:46 -0400

This is an automated email from the git hooks/post-receive script.

pertusus pushed a commit to branch master
in repository texinfo.

The following commit(s) were added to refs/heads/master by this push:
     new c88e1e7b1f * tp/Texinfo/XS/parsetexi/counter.c 
(counter_element_value): add.
c88e1e7b1f is described below

commit c88e1e7b1f968b3a39efd40e8240714f9942ce97
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Jun 9 22:19:14 2024 +0200

    * tp/Texinfo/XS/parsetexi/counter.c (counter_element_value): add.
    
    * tp/Texinfo/XS/parsetexi/macro.c (argument_brace_groups)
    (expand_linemacro_arguments): use an COUNTER counter instead of a
    counter in element, there are few elements, there is no issue with
    linear searching in the counter.
    
    * tp/Texinfo/XS/main/tree_types.h (ELEMENT): remove counter.
---
 ChangeLog                         | 11 +++++++++++
 tp/TODO                           | 19 ++++++++++---------
 tp/Texinfo/XS/main/tree_types.h   |  5 ++---
 tp/Texinfo/XS/parsetexi/counter.c | 18 ++++++++++++++++++
 tp/Texinfo/XS/parsetexi/counter.h |  1 +
 tp/Texinfo/XS/parsetexi/macro.c   | 16 ++++++++++++----
 6 files changed, 54 insertions(+), 16 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 87204eb460..a19eb5acbf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2024-06-09  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/parsetexi/counter.c (counter_element_value): add.
+
+       * tp/Texinfo/XS/parsetexi/macro.c (argument_brace_groups)
+       (expand_linemacro_arguments): use an COUNTER counter instead of a
+       counter in element, there are few elements, there is no issue with
+       linear searching in the counter.
+
+       * tp/Texinfo/XS/main/tree_types.h (ELEMENT): remove counter.
+
 2024-06-09  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/ManipulateTree.pm (_copy_tree): modify code to take into
diff --git a/tp/TODO b/tp/TODO
index 90350cab85..6270a60c2e 100644
--- a/tp/TODO
+++ b/tp/TODO
@@ -86,21 +86,22 @@ ms_print massif_info.out > ms_print_info.out
 5M (approximate, not visible in the detailed use, based on difference
     in use over time) conversion
 
-With full XS
+With full XS (7.2 64M, with text separate 58.5M, without info_info 56M)
 valgrind --tool=massif --massif-out-file=massif_html.out perl -w texi2any.pl 
--html ../doc/texinfo.texi
 ms_print massif_html.out > ms_print_html.out
 useful-heap
-24.9M = 13 + 5.8 + 2.9 + 2.5 + 0.7 Perl
-21.3M Tree
- 8.7 + 5.8 = 14.5M new_element
+24.9M = 13 + 5.3 + 2.9 + 2.5 + 0.7 Perl
+21.2M Tree
+ 7.8 + 5.8 = 13.6M new_element
  3.7M reallocate_list
  1.1M get_associated_info_key
- 2M = 0.7 +1.3 text (+1.4M by approximate difference with total)
-4.5M = 3.8 (text) + 0.7: conversion, mainly text in convert_output_output_unit*
-                  (+2M by approximate difference with total)
-6.9 - (3.8 + 0.7) = 2.4 M Text not imputed
+ 2.8M = 0.7 + 0.8 +1.3 text (+0.6M by approximate difference with total)
+5.2M = 3.8 (text) + 0.7 (text printindex) + 0.7: conversion,
+               mainly text in convert_output_output_unit*
+                  (+1.3M by approximate difference with total)
+(7.6 + 1.3) - (3.8 + 0.7 + 0.7 + 0.8 +1.3) = 1.6 M Text not imputed
 2.5M remaining not imputed
-55.6M TOTAL (for 56M reported)
+55.4M TOTAL (for 55.9M reported)
 
 Texinfo syntax
 
diff --git a/tp/Texinfo/XS/main/tree_types.h b/tp/Texinfo/XS/main/tree_types.h
index 1867fa518a..65b93b0d15 100644
--- a/tp/Texinfo/XS/main/tree_types.h
+++ b/tp/Texinfo/XS/main/tree_types.h
@@ -17,6 +17,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>. */
 
 #include <stddef.h>
+#include <stdint.h>
 
 #include "command_ids.h"
 #include "element_types.h"
@@ -244,14 +245,12 @@ typedef struct ELEMENT {
     void *hv;
 
     enum element_type type;
-    unsigned long flags;
+    uint8_t flags; /* 8 flags, could increase to uint16_t if more are needed */
     struct ELEMENT *parent;
     /* depends on the element, can be space elements, comments */
     struct ELEMENT **elt_info;
     SOURCE_MARK_LIST source_mark_list;
 
-    int counter; /* to be used temporarily and reset to 0 */
-
     enum command_id cmd;
 
     union {
diff --git a/tp/Texinfo/XS/parsetexi/counter.c 
b/tp/Texinfo/XS/parsetexi/counter.c
index 7420bee323..b041859fd6 100644
--- a/tp/Texinfo/XS/parsetexi/counter.c
+++ b/tp/Texinfo/XS/parsetexi/counter.c
@@ -106,6 +106,24 @@ counter_value (COUNTER *c, ELEMENT *elt)
     return -1;
 }
 
+int
+counter_element_value (COUNTER *c, ELEMENT *elt)
+{
+  int i;
+
+  if (c->nvalues > 0)
+    {
+      for (i = 0; i < c->nvalues; i++)
+        {
+          if (c->elts[i] == elt)
+            {
+              return c->values[i];
+            }
+        }
+    }
+  return -1;
+}
+
 /* If NOT_EMPTY_MESSAGE is set, check that the counter values list
    is empty, if not, show a debugging message */
 void
diff --git a/tp/Texinfo/XS/parsetexi/counter.h 
b/tp/Texinfo/XS/parsetexi/counter.h
index f70bfbce4c..55a213b43f 100644
--- a/tp/Texinfo/XS/parsetexi/counter.h
+++ b/tp/Texinfo/XS/parsetexi/counter.h
@@ -33,6 +33,7 @@ void counter_dec (COUNTER *c);
 int counter_remove_element (COUNTER *c, ELEMENT *elt);
 int counter_value (COUNTER *c, ELEMENT *e);
 void counter_reset (COUNTER *c, const char* not_empty_message);
+int counter_element_value (COUNTER *c, ELEMENT *elt);
 
 /* A large positive number used to represent an unlimited number of remaining
    arguments. */
diff --git a/tp/Texinfo/XS/parsetexi/macro.c b/tp/Texinfo/XS/parsetexi/macro.c
index ff32b1d261..59de92c993 100644
--- a/tp/Texinfo/XS/parsetexi/macro.c
+++ b/tp/Texinfo/XS/parsetexi/macro.c
@@ -47,6 +47,8 @@ static size_t macro_space;
 
 static size_t free_slots_nr;
 
+COUNTER argument_brace_groups;
+
 
 /* Macro definition. */
 
@@ -459,6 +461,8 @@ expand_linemacro_arguments (const ELEMENT *macro, const 
char **line_inout,
   add_to_element_contents (argument, argument_content);
   arg = argument_content->e.text;
 
+  counter_push (&argument_brace_groups, argument_content, 0);
+
   spaces_nr = strspn (pline, whitespace_chars_except_newline);
   if (spaces_nr)
     {
@@ -567,7 +571,7 @@ expand_linemacro_arguments (const ELEMENT *macro, const 
char **line_inout,
           text_append_n (arg, sep, 1);
           pline = sep + 1;
           if (braces_level == 0)
-            argument_content->counter++;
+            counter_inc (&argument_brace_groups);
           break;
         /* spaces */
         default:
@@ -585,6 +589,7 @@ expand_linemacro_arguments (const ELEMENT *macro, const 
char **line_inout,
 
               argument = new_element (ET_line_arg);
               argument_content = new_text_element (ET_other_text);
+              counter_push (&argument_brace_groups, argument_content, 0);
 
               add_to_element_args (current, argument);
               add_to_element_contents (argument, argument_content);
@@ -603,8 +608,11 @@ expand_linemacro_arguments (const ELEMENT *macro, const 
char **line_inout,
  funexit:
   for (i = 0; i < current->e.c->args.number; i++)
     {
-      ELEMENT *argument_content = 
current->e.c->args.list[i]->e.c->contents.list[0];
-      if (argument_content->counter == 1)
+      ELEMENT *argument_content
+        = current->e.c->args.list[i]->e.c->contents.list[0];
+      int brace_groups_nr = counter_element_value (&argument_brace_groups,
+                                                   argument_content);
+      if (brace_groups_nr == 1)
         {
           int text_len = strlen (argument_content->e.text->text);
           if (argument_content->e.text->text[0] == '{'
@@ -621,7 +629,7 @@ expand_linemacro_arguments (const ELEMENT *macro, const 
char **line_inout,
               argument_content->type = ET_bracketed_linemacro_arg;
             }
         }
-      argument_content->counter = 0;
+      counter_remove_element (&argument_brace_groups, argument_content);
     }
   debug ("END LINEMACRO ARGS EXPANSION");
 



reply via email to

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