On Sun, Oct 06, 2024 at 09:53:22AM +0200, Patrice Dumas wrote: > > How much slower would the linear search actually be? > > It is much slower (if I recall well, it was something like 100 times > slower for the texi2any manual). I juste tested the overall effect and > for the pure C demonstrator for the Texinfo manual, time is about 0.375 > s with linear search and 0.305 with the hash map.
That is a 20% decrease which is significant, but is only 0.07 sec absolute difference in run time. Does it scale with the size of the input? Perhaps a certain part of this 0.07 sec is fixed regardless of the size of the input file. Have you tried it with a larger manual like glibc or elisp? > > > To me, this C++ is not really in Texinfo code, it is more like an > > > external C library that happens to be in C++, but it is well > > > separated. > > > > It doesn't appear this way to me. tp/Texinfo/XS/configure.ac checks > > for a C++ compiler with AC_PROG_CXX. So it is seems that present a > > C++ compiler is required to build Texinfo. > > It is not required. If there is no C++ compiler the linear search is > used in the demonstrator program. I checked this by running "./configure CXX=xxx". configure detects that this doesn't work: checking if C++ hashmap can be used... no > > There is also a C++ source > > file under tp/Texinfo/XS/convert/call_html_cxx_function.cpp in the same > > subdirectory as other source code files for the program. > > Of course there need to be one, but it is the only one and it just > implements the few functions needed to do the job (wrapped as C > functions). > > > > If needed, I could try to make it part of contrib/ instead of being in > > > the main code. > > > > That would be an improvement. > > After more thinking, I wonder if it wouldn't be better to require > setting a configure flag to have the teximakehtml demonstrator program > built instead of moving the C++ code to contrib, as it would be much > simpler. The configure flag would be a good thing as at present, object files with names like ./parsetexi/teximakehtml-context_stack.o are created throughout the build directory. I will try to understand how the C++ source file is used to see if I can propose any way of separating it better.