[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Sat, 28 Sep 2024 18:20:04 -0400 (EDT) |
branch: master
commit d10ff505d04a21bd383aab5dbdd670ecedcc562b
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Jun 2 23:41:33 2024 +0200
* tp/Texinfo/XS/main/build_perl_info.c (store_additional_info)
(element_to_perl_hash): pass the number of information to
store_additional_info, and if some information is already set reuse
the HV.
* tp/Texinfo/XS/main/build_perl_info.c (element_to_perl_hash),
tp/Texinfo/XS/main/convert_to_texinfo.c (expand_cmd_args_to_texi)
(convert_to_texinfo_internal), tp/Texinfo/XS/main/manipulate_tree.c
(copy_tree_internal), tp/Texinfo/XS/main/tree_types.h (ELEMENT),
tp/Texinfo/XS/parsetexi/def.c (parse_def),
tp/Texinfo/XS/parsetexi/end_line.c (end_line_starting_block): set
inserted directly in the ELEMENT structure instead of in the info
additional information.
---
ChangeLog | 16 +++++++++++++
tp/Texinfo/XS/main/build_perl_info.c | 40 +++++++++++++++++++++++----------
tp/Texinfo/XS/main/convert_to_texinfo.c | 8 ++-----
tp/Texinfo/XS/main/manipulate_tree.c | 2 ++
tp/Texinfo/XS/main/tree_types.h | 1 +
tp/Texinfo/XS/parsetexi/def.c | 4 ++--
tp/Texinfo/XS/parsetexi/end_line.c | 4 ++--
7 files changed, 53 insertions(+), 22 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index d0be7a84f5..98e297fccd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,22 @@
Update test result
+2024-06-01 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/XS/main/build_perl_info.c (store_additional_info)
+ (element_to_perl_hash): pass the number of information to
+ store_additional_info, and if some information is already set reuse
+ the HV.
+
+ * tp/Texinfo/XS/main/build_perl_info.c (element_to_perl_hash),
+ tp/Texinfo/XS/main/convert_to_texinfo.c (expand_cmd_args_to_texi)
+ (convert_to_texinfo_internal), tp/Texinfo/XS/main/manipulate_tree.c
+ (copy_tree_internal), tp/Texinfo/XS/main/tree_types.h (ELEMENT),
+ tp/Texinfo/XS/parsetexi/def.c (parse_def),
+ tp/Texinfo/XS/parsetexi/end_line.c (end_line_starting_block): set
+ inserted directly in the ELEMENT structure instead of in the info
+ additional information.
+
2024-06-01 Patrice Dumas <pertusus@free.fr>
Type brace_command_container for brace_command_arg without spaces
diff --git a/tp/Texinfo/XS/main/build_perl_info.c
b/tp/Texinfo/XS/main/build_perl_info.c
index 7a0fbab2d5..e6788783bc 100644
--- a/tp/Texinfo/XS/main/build_perl_info.c
+++ b/tp/Texinfo/XS/main/build_perl_info.c
@@ -288,8 +288,6 @@ build_additional_info (HV *extra, const ASSOCIATED_INFO *a,
{
dTHX;
- *nr_info = 0; /* number of info type stored */
-
if (a->info_number > 0)
{
int i;
@@ -432,21 +430,25 @@ build_additional_info (HV *extra, const ASSOCIATED_INFO
*a,
static void
store_additional_info (const ELEMENT *e, const ASSOCIATED_INFO *a,
- const char *key, int avoid_recursion)
+ const char *key, int *nr_info, int avoid_recursion)
{
- int nr_info;
HV *additional_info_hv;
dTHX;
- /* Use sv_2mortal so that reference count is decremented if
- the hash is not saved. */
- additional_info_hv = (HV *) sv_2mortal ((SV *)newHV ());
-
+ if (*nr_info == 0)
+ /* Use sv_2mortal so that reference count is decremented if
+ the hash is not saved. */
+ additional_info_hv = (HV *) sv_2mortal ((SV *)newHV ());
+ else
+ {
+ SV **additional_info_sv = hv_fetch (e->hv, key, strlen (key), 0);
+ additional_info_hv = (HV *)SvRV (*additional_info_sv);
+ }
- build_additional_info (additional_info_hv, a, avoid_recursion, &nr_info);
+ build_additional_info (additional_info_hv, a, avoid_recursion, nr_info);
- if (nr_info > 0)
+ if (*nr_info > 0)
hv_store (e->hv, key, strlen (key),
newRV_inc ((SV *)additional_info_hv), 0);
}
@@ -561,6 +563,8 @@ void
element_to_perl_hash (ELEMENT *e, int avoid_recursion)
{
SV *sv;
+ int nr_info = 0;
+ int nr_extra = 0;
dTHX;
@@ -622,7 +626,16 @@ element_to_perl_hash (ELEMENT *e, int avoid_recursion)
hv_store (e->hv, "type", strlen ("type"), sv, HSH_type);
}
- store_additional_info (e, &e->info_info, "info", avoid_recursion);
+ if (e->inserted)
+ {
+ HV *info_hv = (HV *) sv_2mortal ((SV *)newHV ());
+ const char *key = "info";
+ hv_store (info_hv, "inserted", strlen ("inserted"),
+ newSViv (1), 0);
+ hv_store (e->hv, key, strlen (key),
+ newRV_inc ((SV *)info_hv), 0);
+ nr_info++;
+ }
if (type_data[e->type].flags & TF_text)
{
@@ -633,6 +646,8 @@ element_to_perl_hash (ELEMENT *e, int avoid_recursion)
/* non-text elements */
+ store_additional_info (e, &e->info_info, "info", &nr_info, avoid_recursion);
+
if (e->cmd)
{
sv = newSVpv (element_command_name (e), 0);
@@ -686,7 +701,8 @@ element_to_perl_hash (ELEMENT *e, int avoid_recursion)
}
}
- store_additional_info (e, &e->extra_info, "extra", avoid_recursion);
+ store_additional_info (e, &e->extra_info, "extra", &nr_extra,
+ avoid_recursion);
if (e->c->associated_unit)
{
diff --git a/tp/Texinfo/XS/main/convert_to_texinfo.c
b/tp/Texinfo/XS/main/convert_to_texinfo.c
index ada39ae5a6..ab7ff3f148 100644
--- a/tp/Texinfo/XS/main/convert_to_texinfo.c
+++ b/tp/Texinfo/XS/main/convert_to_texinfo.c
@@ -101,9 +101,7 @@ expand_cmd_args_to_texi (const ELEMENT *e, TEXT *result)
for (i = 0; i < e->c->args.number; i++)
{
ELEMENT *arg = e->c->args.list[i];
- int status;
- int inserted = lookup_info_integer (arg, "inserted", &status);
- if (inserted)
+ if (arg->inserted)
continue;
if (with_commas)
@@ -135,10 +133,8 @@ static void
convert_to_texinfo_internal (const ELEMENT *e, TEXT *result)
{
ELEMENT *elt;
- int status;
- int inserted = lookup_info_integer (e, "inserted", &status);
- if (inserted)
+ if (e->inserted)
{}
else if (type_data[e->type].flags & TF_text)
{
diff --git a/tp/Texinfo/XS/main/manipulate_tree.c
b/tp/Texinfo/XS/main/manipulate_tree.c
index 54f42695e5..9cd95217e2 100644
--- a/tp/Texinfo/XS/main/manipulate_tree.c
+++ b/tp/Texinfo/XS/main/manipulate_tree.c
@@ -166,6 +166,8 @@ copy_tree_internal (ELEMENT* current, ELEMENT *parent)
else
new = new_element (current->type);
+ new->inserted = current->inserted;
+
increase_ref_counter (current);
add_extra_element (current, "_copy", new);
diff --git a/tp/Texinfo/XS/main/tree_types.h b/tp/Texinfo/XS/main/tree_types.h
index 29e1bcea87..773a592ace 100644
--- a/tp/Texinfo/XS/main/tree_types.h
+++ b/tp/Texinfo/XS/main/tree_types.h
@@ -222,6 +222,7 @@ typedef struct ELEMENT {
void *hv;
enum element_type type;
+ unsigned long inserted;
struct ELEMENT *parent;
SOURCE_MARK_LIST source_mark_list;
diff --git a/tp/Texinfo/XS/parsetexi/def.c b/tp/Texinfo/XS/parsetexi/def.c
index ff66648629..cd111b13ce 100644
--- a/tp/Texinfo/XS/parsetexi/def.c
+++ b/tp/Texinfo/XS/parsetexi/def.c
@@ -399,7 +399,7 @@ parse_def (enum command_id command, ELEMENT *current)
e = new_text_element (ET_spaces);
text_append_n (e->text, " ", 1);
- add_info_integer (e, "inserted", 1);
+ e->inserted = 1;
insert_into_contents (current, e, contents_idx + 1);
}
@@ -444,7 +444,7 @@ parse_def (enum command_id command, ELEMENT *current)
if (inserted_category)
{
- add_info_integer (current->c->contents.list[0], "inserted", 1);
+ current->c->contents.list[0]->inserted = 1;
}
/* Process args */
diff --git a/tp/Texinfo/XS/parsetexi/end_line.c
b/tp/Texinfo/XS/parsetexi/end_line.c
index 8765310023..e9bc1b6ce0 100644
--- a/tp/Texinfo/XS/parsetexi/end_line.c
+++ b/tp/Texinfo/XS/parsetexi/end_line.c
@@ -1061,7 +1061,7 @@ end_line_starting_block (ELEMENT *current)
}
e = new_element (ET_command_as_argument);
- add_info_integer (e, "inserted", 1);
+ e->inserted = 1;
e->cmd = CM_bullet;
insert_into_contents (block_line_arg, e, 0);
add_extra_element (current, "command_as_argument", e);
@@ -1072,7 +1072,7 @@ end_line_starting_block (ELEMENT *current)
ELEMENT *e;
e = new_element (ET_command_as_argument);
- add_info_integer (e, "inserted", 1);
+ e->inserted = 1;
e->cmd = CM_asis;
insert_into_args (current, e, 0);
add_extra_element (current, "command_as_argument", e);