[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Patrice Dumas |
Date: |
Sun, 29 Sep 2024 04:45:27 -0400 (EDT) |
branch: master
commit 09d13388685d0a3726d283048418e2cb1c423c05
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Jun 9 17:00:10 2024 +0200
* tp/Texinfo/ManipulateTree.pm (_copy_tree): modify code to take into
acocunt that there is no command name in text and be more similar with
C code.
---
ChangeLog | 6 ++++++
tp/TODO | 24 +++++++++++++-----------
tp/Texinfo/ManipulateTree.pm | 19 ++++++++-----------
3 files changed, 27 insertions(+), 22 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 3405d4ed6e..87204eb460 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-06-09 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/ManipulateTree.pm (_copy_tree): modify code to take into
+ acocunt that there is no command name in text and be more similar with
+ C code.
+
2024-06-09 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XS/structuring_transfo/transformations.c
diff --git a/tp/TODO b/tp/TODO
index 04af071287..28a907c3e3 100644
--- a/tp/TODO
+++ b/tp/TODO
@@ -99,7 +99,7 @@ line/block commands args brace_arg bracketed_arg
EXCEPTION: needed transient _copy and _counter in copy_tree_internal in
extra
-valgrinf massif useful-heap approximate distribution in 2024
+valgrinf massif useful-heap approximate distribution in 2024 (obsolete)
valgrind --tool=massif --massif-out-file=massif_info.out perl -w texi2any.pl
../doc/texinfo.texi
ms_print massif_info.out > ms_print_info.out
16M Perl
@@ -113,16 +113,18 @@ ms_print massif_info.out > ms_print_info.out
With full XS
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
-25.1M Perl
-25M C tree
-5.6M conversion, mainly text in convert_output_output_unit_internal and
- secondarily, in printindex
-Text not imputed 1.7M
-Remaining not imputed 2.4M
-Detailed memory use for tree is mainly alloc_element (16.2M), secondarily
-reallocate_list (3.7M) and get_associated_info_key (3.1M) and text
-is small (2M).
-
+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
+ 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.5M remaining not imputed
+55.6M TOTAL (for 56M reported)
Texinfo syntax
diff --git a/tp/Texinfo/ManipulateTree.pm b/tp/Texinfo/ManipulateTree.pm
index 8d4302c78b..08bb11e9d1 100644
--- a/tp/Texinfo/ManipulateTree.pm
+++ b/tp/Texinfo/ManipulateTree.pm
@@ -99,15 +99,11 @@ sub import {
# TODO document in POD?
-# This implementation of tree copy is designed such as to be
-# implementable easily in XS with reference to copy local to
-# the element and not in a hash
-
-# It is important to go through the tree in the same order
-# in _copy_tree and _copy_extra_info, to be sure that elements already
-# seen are the same in both cases, such that _counter is at 0 in
-# _copy_extra_info when all the dependent elements have been seen
-# and going through the target element.
+# To do the copy, we do two pass. First with copy_tree_internal, the tree is
+# copied and a reference to the copy is put in all the elements,
+# taking care that each element is processed once only.
+# Then, remove_element_copy_info goes through the tree again and remove
+# the references to the copies.
# the *_directions extra items are not elements, they contain
# up, next and prev that point to elements.
@@ -134,7 +130,7 @@ sub _copy_tree($)
}
my $new = {};
- foreach my $key ('type', 'cmdname', 'text') {
+ foreach my $key ('type', 'text') {
$new->{$key} = $current->{$key} if (exists($current->{$key}));
}
@@ -148,7 +144,8 @@ sub _copy_tree($)
}
my $command_or_type = '';
- if ($current->{'cmdname'}) {
+ if (defined($current->{'cmdname'})) {
+ $new->{'cmdname'} = $current->{'cmdname'};
$command_or_type = '@'.$current->{'cmdname'};
} elsif ($current->{'type'}) {
$command_or_type = $current->{'type'};