texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/XS/convert/ConvertXS.xs (generic_con


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/XS/convert/ConvertXS.xs (generic_converter_init), tp/Texinfo/XS/convert/convert_html.c, tp/Texinfo/XS/convert/converter.c (new_converter), tp/Texinfo/XS/main/converter_types.h (enum ids_data_type, CONVERTER): make the choice between perl_hashmap and string_list for html ids storage and retrieval a runtime choice. Add ids_data_type field in CONVERTER to register and retrieve the choice. Add a flags argument to new_converter to pass low level implementation configuration, such [...]
Date: Fri, 04 Oct 2024 06:15:06 -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 6a09f65128 * tp/Texinfo/XS/convert/ConvertXS.xs 
(generic_converter_init), tp/Texinfo/XS/convert/convert_html.c, 
tp/Texinfo/XS/convert/converter.c (new_converter), 
tp/Texinfo/XS/main/converter_types.h (enum ids_data_type, CONVERTER): make the 
choice between perl_hashmap and string_list for html ids storage and retrieval 
a runtime choice.  Add ids_data_type field in CONVERTER to register and 
retrieve the choice.  Add a flags argument to new_converter to pass low level 
implementatio [...]
6a09f65128 is described below

commit 6a09f651281ca897f2aa59f1b7bc32740506b9b6
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Aug 11 15:28:01 2024 +0200

    * tp/Texinfo/XS/convert/ConvertXS.xs (generic_converter_init),
    tp/Texinfo/XS/convert/convert_html.c,
    tp/Texinfo/XS/convert/converter.c (new_converter),
    tp/Texinfo/XS/main/converter_types.h (enum ids_data_type, CONVERTER):
    make the choice between perl_hashmap and string_list for html ids
    storage and retrieval a runtime choice.  Add ids_data_type field in
    CONVERTER to register and retrieve the choice.  Add a flags argument
    to new_converter to pass low level implementation configuration, such
    as the ids data use.
---
 ChangeLog                            | 12 ++++++++
 tp/TODO                              |  1 +
 tp/Texinfo/XS/convert/ConvertXS.xs   |  6 +++-
 tp/Texinfo/XS/convert/convert_html.c | 55 ++++++++++++++++--------------------
 tp/Texinfo/XS/convert/converter.c    | 10 ++++++-
 tp/Texinfo/XS/convert/converter.h    |  2 +-
 tp/Texinfo/XS/convert/texinfo.c      |  2 +-
 tp/Texinfo/XS/main/converter_types.h | 10 +++++++
 8 files changed, 63 insertions(+), 35 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e144865170..3a86ce0ff3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2024-08-11  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/convert/ConvertXS.xs (generic_converter_init),
+       tp/Texinfo/XS/convert/convert_html.c,
+       tp/Texinfo/XS/convert/converter.c (new_converter),
+       tp/Texinfo/XS/main/converter_types.h (enum ids_data_type, CONVERTER):
+       make the choice between perl_hashmap and string_list for html ids
+       storage and retrieval a runtime choice.  Add ids_data_type field in
+       CONVERTER to register and retrieve the choice.  Add a flags argument
+       to new_converter to pass low level implementation configuration, such
+       as the ids data use.
+
 2024-08-11  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/teximakehtml.c (main): do not add errors_nr to the
diff --git a/tp/TODO b/tp/TODO
index a068bbc32b..b7e0d0398d 100644
--- a/tp/TODO
+++ b/tp/TODO
@@ -894,6 +894,7 @@ our_CFLAGS='-g -O0 -Wformat-security -Wstrict-prototypes 
-Wall -Wno-parentheses
 # some features are only enabled at -O2, but sometime -O0 is better
 # for debugging with valgrind
 our_CFLAGS='-g -O2 -D_FORTIFY_SOURCE=2 -Wformat-security -Wstrict-prototypes 
-Wall -Wno-parentheses -Wno-missing-braces -Wno-unused-parameter 
-fstack-protector-all -Wextra -Wno-sign-compare -fno-omit-frame-pointer'
+our_CFLAGS='-g -O2 -Wformat-security -Wstrict-prototypes -Wall 
-Wno-parentheses -Wno-missing-braces -Wno-unused-parameter -Wextra 
-Wno-sign-compare'
 ./configure "CFLAGS=$our_CFLAGS" "PERL_EXT_CFLAGS=$our_CFLAGS"
 unset our_CFLAGS
 
diff --git a/tp/Texinfo/XS/convert/ConvertXS.xs 
b/tp/Texinfo/XS/convert/ConvertXS.xs
index 24b9fbb956..cb6b20fece 100644
--- a/tp/Texinfo/XS/convert/ConvertXS.xs
+++ b/tp/Texinfo/XS/convert/ConvertXS.xs
@@ -114,7 +114,11 @@ generic_converter_init (SV *converter_in, const char 
*class, SV *format_defaults
                }
            }
 
-         converter_descriptor = new_converter (converter_format);
+         converter_descriptor = new_converter (converter_format,
+                                               CONVF_perl_hashmap);
+                                               /*
+                                               CONVF_string_list);
+                                                */
          self = retrieve_converter (converter_descriptor);
 
          format_defaults = new_converter_initialization_info ();
diff --git a/tp/Texinfo/XS/convert/convert_html.c 
b/tp/Texinfo/XS/convert/convert_html.c
index 658b910a2b..0ae4da1293 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -66,11 +66,6 @@
 #include "api_to_perl.h"
 #include "convert_html.h"
 
-/* comment out to use a string list in pure C instead, with linear search.
-   Using a Perl hash map is much faster.
- */
-#define USE_PERL_HASHMAP 1
-
 typedef struct ROOT_AND_UNIT {
     const OUTPUT_UNIT *output_unit;
     const ELEMENT *root;
@@ -324,21 +319,19 @@ static void convert_to_html_internal (CONVERTER *self, 
const ELEMENT *e,
 int
 html_id_is_registered (CONVERTER *self, const char *string)
 {
-#ifdef USE_PERL_HASHMAP
-  return is_hv_registered_id (self, string);
-#else
-  return find_string (self->registered_ids, string);
-#endif
+  if (self->ids_data_type == IDT_perl_hashmap)
+    return is_hv_registered_id (self, string);
+  else
+    return find_string (self->registered_ids, string);
 }
 
 void
 html_register_id (CONVERTER *self, const char *string)
 {
-#ifdef USE_PERL_HASHMAP
-  hv_register_id (self, string);
-#else
-  add_string (string, self->registered_ids);
-#endif
+  if (self->ids_data_type == IDT_perl_hashmap)
+    hv_register_id (self, string);
+  else
+    add_string (string, self->registered_ids);
 }
 
 /*
@@ -17574,11 +17567,10 @@ html_converter_customize (CONVERTER *self)
   int external_type_open_function = 0;
   int external_formatting_function = 0;
 
-#ifdef USE_PERL_HASHMAP
-  init_registered_ids_hv (self);
-#else
-  self->registered_ids = new_string_list ();
-#endif
+  if (self->ids_data_type == IDT_perl_hashmap)
+    init_registered_ids_hv (self);
+  else
+    self->registered_ids = new_string_list ();
 
   /* for @sc */
   for (i = 0; default_upper_case_commands[i]; i++)
@@ -19615,11 +19607,11 @@ html_reset_converter (CONVERTER *self)
   reset_translated_special_unit_info_tree (self);
   /* targets */
   reset_html_targets (self, self->html_targets);
-#ifdef USE_PERL_HASHMAP
-  clear_registered_ids_hv (self);
-#else
-  clear_strings_list (self->registered_ids);
-#endif
+
+  if (self->ids_data_type == IDT_perl_hashmap)
+    clear_registered_ids_hv (self);
+  else
+    clear_strings_list (self->registered_ids);
   for (i = 0; i < ST_footnote_location+1; i++)
     {
       reset_html_targets_list (self, &self->html_special_targets[i]);
@@ -19813,12 +19805,13 @@ html_free_converter (CONVERTER *self)
 
   free (self->html_target_cmds.stack);
 
-#ifdef USE_PERL_HASHMAP
-  free_registered_ids_hv (self);
-#else
-  destroy_strings_list (self->registered_ids);
-  self->registered_ids = 0;
-#endif
+  if (self->ids_data_type == IDT_perl_hashmap)
+    free_registered_ids_hv (self);
+  else
+    {
+      destroy_strings_list (self->registered_ids);
+      self->registered_ids = 0;
+    }
 
   if (self->pl_info_hv)
     {
diff --git a/tp/Texinfo/XS/convert/converter.c 
b/tp/Texinfo/XS/convert/converter.c
index 793ed5c8f4..b643a4fc6b 100644
--- a/tp/Texinfo/XS/convert/converter.c
+++ b/tp/Texinfo/XS/convert/converter.c
@@ -220,8 +220,10 @@ init_generic_converter (CONVERTER *self)
 }
 
 /* descriptor starts at 1, 0 is not found or an error */
+/* flags set low-level implementation choices, currently using Perl hash
+ * map or (slower) string lists */
 size_t
-new_converter (enum converter_format format)
+new_converter (enum converter_format format, unsigned long flags)
 {
   size_t converter_index;
   int slot_found = 0;
@@ -253,6 +255,12 @@ new_converter (enum converter_format format)
 
   registered_converter->format = format;
 
+  /* set low level data representations options */
+  if (flags & CONVF_string_list)
+    registered_converter->ids_data_type = IDT_string_list;
+  else
+    registered_converter->ids_data_type = IDT_perl_hashmap;
+
   init_generic_converter (registered_converter);
 
   converter_list[converter_index] = registered_converter;
diff --git a/tp/Texinfo/XS/convert/converter.h 
b/tp/Texinfo/XS/convert/converter.h
index e6e261aabd..18b038de8e 100644
--- a/tp/Texinfo/XS/convert/converter.h
+++ b/tp/Texinfo/XS/convert/converter.h
@@ -123,7 +123,7 @@ void converter_setup (int texinfo_uninstalled, const char 
*tp_builddir,
 enum converter_format find_format_data_index (const char *format);
 
 CONVERTER *retrieve_converter (int converter_descriptor);
-size_t new_converter (enum converter_format format);
+size_t new_converter (enum converter_format format, unsigned long flags);
 void unregister_converter_descriptor (int converter_descriptor);
 
 void set_converter_init_information (CONVERTER *converter,
diff --git a/tp/Texinfo/XS/convert/texinfo.c b/tp/Texinfo/XS/convert/texinfo.c
index 4d359039f6..3cb47c25c7 100644
--- a/tp/Texinfo/XS/convert/texinfo.c
+++ b/tp/Texinfo/XS/convert/texinfo.c
@@ -277,7 +277,7 @@ txi_complete_document (DOCUMENT *document, unsigned long 
flags,
 CONVERTER *
 txi_converter (enum converter_format format)
 {
-  size_t converter_descriptor = new_converter (format);
+  size_t converter_descriptor = new_converter (format, CONVF_string_list);
   return retrieve_converter (converter_descriptor);
 }
 
diff --git a/tp/Texinfo/XS/main/converter_types.h 
b/tp/Texinfo/XS/main/converter_types.h
index 9e68ed4036..f25ed821fd 100644
--- a/tp/Texinfo/XS/main/converter_types.h
+++ b/tp/Texinfo/XS/main/converter_types.h
@@ -37,6 +37,15 @@ enum converter_format {
    COF_html,
 };
 
+enum ids_data_type {
+   IDT_perl_hashmap,
+   IDT_string_list,
+};
+
+/* converter low level customization */
+#define CONVF_perl_hashmap        0x0001
+#define CONVF_string_list         0x0002
+
 /* for string information passing to/from perl */
 enum sv_string_type {
    svt_byte,
@@ -787,6 +796,7 @@ typedef struct CONVERTER {
 
   /* HTML specific */
     /* set for a converter */
+    enum ids_data_type ids_data_type;
     int external_references_number; /* total number of external references
                                        that could be called */
     int code_types[TXI_TREE_TYPES_NUMBER];



reply via email to

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