From 7fe4092d8e56e2db9f854848425a2101772546b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Thu, 3 Feb 2022 14:26:14 +0100 Subject: [PATCH] groupthm: speedup caching replacing # in cached expressions only when necessary speeds up usage --- src/environments/groupthm/groupthm.dtx | 33 +++++++++++++++++--------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/src/environments/groupthm/groupthm.dtx b/src/environments/groupthm/groupthm.dtx index 282bca6..943b9e9 100644 --- a/src/environments/groupthm/groupthm.dtx +++ b/src/environments/groupthm/groupthm.dtx @@ -2616,7 +2616,7 @@ % Cache this definition for re-runs of \LaTeX. % % \begin{macrocode} - \@@_cache:n + \@@_cache_slow:n { \csname @@_define_family_options:nnnn \endcsname { #1 } { #2 } { #3 } { #4 } } @@ -2864,15 +2864,26 @@ % for details. % % \begin{macrocode} - \cs_new:Npn \@@_cache:n #1 - { - \tl_set:Nn \l_tmpa_tl - { - { #1 } - } - \regex_replace_all:nnN { \cP\# } { \cO\# } \l_tmpa_tl - \@@_cache_auxfile:V \l_tmpa_tl - } + \cs_set_eq:NN \@@_cache:n \@@_cache_auxfile:n +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\@@_cache_slow:n} +% +% +% +% \begin{macrocode} + \cs_new:Npn \@@_cache_slow:n #1 + { + \tl_set:Nn \l_tmpa_tl + { + { #1 } + } + \regex_replace_all:nnN { \cP\# } { \cO\# } \l_tmpa_tl + \@@_cache_auxfile:V \l_tmpa_tl + } % \end{macrocode} % \end{macro} % @@ -2889,7 +2900,7 @@ \tl_use:N \g_@@_lazy_document_tl } { - \cs_show:N \g_@@_lazy_auxfile_tl + \exp_args:NNV \iow_now:Nn \l_my_iow \g_@@_lazy_auxfile_tl \benchmark_once:n { \tl_use:N \g_@@_lazy_auxfile_tl