[latex3-commits] [latex3/latex3] main: Reduce hash-table usage of l3keys slightly (8dbe0a2d6)

github at latex-project.org github at latex-project.org
Fri Jan 12 08:25:02 CET 2024


Repository : https://github.com/latex3/latex3
On branch  : main
Link       : https://github.com/latex3/latex3/commit/8dbe0a2d69ffae77aea70347d686995d006e8a31

>---------------------------------------------------------------

commit 8dbe0a2d69ffae77aea70347d686995d006e8a31
Author: Bruno Le Floch <blflatex at gmail.com>
Date:   Thu Jan 11 23:57:08 2024 +0100

    Reduce hash-table usage of l3keys slightly
    
    Change low-level code to undefine some keys data into a common
    auxiliary that is a local version of \cs_undefine:c which avoids
    using a hash-table entry if the thing is already undefined.


>---------------------------------------------------------------

8dbe0a2d69ffae77aea70347d686995d006e8a31
 l3kernel/l3keys.dtx | 28 ++++++++++++++++++++--------
 1 file changed, 20 insertions(+), 8 deletions(-)

diff --git a/l3kernel/l3keys.dtx b/l3kernel/l3keys.dtx
index d3171ade8..a81d5397f 100644
--- a/l3kernel/l3keys.dtx
+++ b/l3kernel/l3keys.dtx
@@ -1761,6 +1761,21 @@
 %    \end{macrocode}
 % \end{macro}
 %
+% \begin{macro}{\@@_cs_undefine:c}
+%   Local version of \cs{cs_undefine:c} to avoid sprinkling
+%   \cs{tex_undefined:D} everywhere.
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_cs_undefine:c #1
+  {
+    \if_cs_exist:w #1 \cs_end:
+    \else:
+      \use_i:nnnn
+    \fi:
+    \cs_set_eq:cN {#1} \tex_undefined:D
+  }
+%    \end{macrocode}
+% \end{macro}
+%
 % \subsection{The key defining mechanism}
 %
 % \begin{macro}{\keys_define:nn, \keys_define:ne, \keys_define:nx}
@@ -2067,9 +2082,8 @@
   {
     \tl_if_empty:nTF {#1}
       {
-        \cs_set_eq:cN
+        \@@_cs_undefine:c
           { \c_@@_default_root_str \l_keys_path_str }
-          \tex_undefined:D
       }
       {
         \cs_set_nopar:cpe
@@ -2093,8 +2107,8 @@
     \clist_set:Ne \l_@@_groups_clist { \tl_to_str:n {#1} }
     \clist_if_empty:NTF \l_@@_groups_clist
       {
-        \cs_set_eq:cN { \c_@@_groups_root_str \l_keys_path_str }
-          \tex_undefined:D
+        \@@_cs_undefine:c
+          { \c_@@_groups_root_str \l_keys_path_str }
       }
       {
         \cs_set_eq:cN { \c_@@_groups_root_str \l_keys_path_str }
@@ -2228,9 +2242,8 @@
     \clist_map_inline:nn
       { code , default , groups , inherit , type , check }
       {
-        \cs_set_eq:cN
+        \@@_cs_undefine:c
           { \tl_use:c { c_@@_ ##1 _root_str } \l_keys_path_str }
-          \tex_undefined:D
       }
   }
 %    \end{macrocode}
@@ -2260,9 +2273,8 @@
               { \c_@@_check_root_str \l_keys_path_str }
               { @@_check_ #1 : }
               {
-                \cs_set_eq:cN
+                \@@_cs_undefine:c
                   { \c_@@_check_root_str \l_keys_path_str }
-                  \tex_undefined:D
               }
           }
       }





More information about the latex3-commits mailing list.