[latex3-commits] [git/LaTeX3-latex3-latex2e] keyval-detect: Less argument passing-around (9635911d)

Joseph Wright joseph.wright at morningstar2.co.uk
Wed Aug 31 08:27:16 CEST 2022


Repository : https://github.com/latex3/latex2e
On branch  : keyval-detect
Link       : https://github.com/latex3/latex2e/commit/9635911ded1cfdde38d0e66edc05ec9ebccb22f1

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

commit 9635911ded1cfdde38d0e66edc05ec9ebccb22f1
Author: PhelypeOleinik <phelype.oleinik at latex-project.org>
Date:   Mon Aug 29 17:57:16 2022 -0300

    Less argument passing-around
    
    Moved the default key and the unchanged argument to the end


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

9635911ded1cfdde38d0e66edc05ec9ebccb22f1
 base/ltcmd.dtx | 106 ++++++++++++++++++++++++++++++---------------------------
 1 file changed, 56 insertions(+), 50 deletions(-)

diff --git a/base/ltcmd.dtx b/base/ltcmd.dtx
index 6776ae58..dff5d652 100644
--- a/base/ltcmd.dtx
+++ b/base/ltcmd.dtx
@@ -3968,14 +3968,16 @@
 % \begin{macro}{\@@_arg_to_keyvalue_auxiii:nnn}
 % \begin{macro}{\@@_arg_to_keyvalue_auxiv:nnNw}
 % \begin{macro}{\@@_arg_to_keyvalue_auxv:nn}
-% \begin{macro}{\@@_arg_to_keyvalue_loop:nnw}
-% \begin{macro}{\@@_arg_to_keyvalue_loop_group:nnn}
-% \begin{macro}{\@@_arg_to_keyvalue_loop_space:nnw}
-% \begin{macro}{\@@_arg_to_keyvalue_loop_N_type:nnN}
-% \begin{macro}{\@@_arg_to_keyvalue_math:nnw}
-% \begin{macro}{\@@_arg_to_keyvalue_math_N_type:nnN}
-% \begin{macro}{\@@_arg_to_keyvalue_math_group:nnn}
-% \begin{macro}{\@@_arg_to_keyvalue_math_space:nnw}
+% \begin{macro}{\@@_arg_to_keyvalue_loop:w}
+% \begin{macro}{\@@_arg_to_keyvalue_loop_group:n}
+% \begin{macro}{\@@_arg_to_keyvalue_loop_space:w}
+% \begin{macro}{\@@_arg_to_keyvalue_loop_N_type:N}
+% \begin{macro}{\@@_arg_to_keyvalue_math:w}
+% \begin{macro}{\@@_arg_to_keyvalue_math_N_type:N}
+% \begin{macro}{\@@_arg_to_keyvalue_math_group:n}
+% \begin{macro}{\@@_arg_to_keyvalue_math_space:w}
+% \begin{macro}{\@@_arg_to_keyvalue_set_default:nn}
+% \begin{macro}{\@@_arg_to_keyvalue_set_keyvalue:nn}
 %   If the entire argument is braced, we treat as free text and return as
 %   the value for the text key. Alternatively, if the start of the input is
 %   |=,| then it is forced to be key--value. To avoid needing to worry about
@@ -4037,68 +4039,70 @@
 %    \begin{macrocode}
 \cs_new_protected:Npn \@@_arg_to_keyvalue_auxv:nn #1#2
   {
-    \@@_arg_to_keyvalue_loop:nnw {#1} {#2} #2
-      \q_recursion_tail \q_recursion_stop
+    \@@_arg_to_keyvalue_loop:w #2
+      \q_recursion_tail \q_recursion_stop {#1} {#2}
   }
-\cs_new_protected:Npn \@@_arg_to_keyvalue_loop:nnw
-  #1#2#3 \q_recursion_stop
+\cs_new_protected:Npn \@@_arg_to_keyvalue_loop:w #1 \q_recursion_stop
   {
-    \tl_if_head_is_N_type:nTF {#3}
-      { \@@_arg_to_keyvalue_loop_N_type:nnN }
+    \tl_if_head_is_N_type:nTF {#1}
+      { \@@_arg_to_keyvalue_loop_N_type:N }
       {
-        \tl_if_head_is_group:nTF {#3}
-          { \@@_arg_to_keyvalue_loop_group:nnn }
-          { \@@_arg_to_keyvalue_loop_space:nnw }
+        \tl_if_head_is_group:nTF {#1}
+          { \@@_arg_to_keyvalue_loop_group:n }
+          { \@@_arg_to_keyvalue_loop_space:w }
       }
-        {#1} {#2} #3 \q_recursion_stop
+        #1 \q_recursion_stop
   }
-\cs_new_protected:Npn \@@_arg_to_keyvalue_loop_group:nnn #1#2#3
-  { \@@_arg_to_keyvalue_loop:nnw {#1} {#2} }
-\cs_new_protected:Npn \@@_arg_to_keyvalue_loop_space:nnw #1#2 ~
-  { \@@_arg_to_keyvalue_loop:nnw {#1} {#2} }
-\cs_new_protected:Npn \@@_arg_to_keyvalue_loop_N_type:nnN #1#2#3
+\cs_new_protected:Npn \@@_arg_to_keyvalue_loop_group:n #1
+  { \@@_arg_to_keyvalue_loop:w }
+\use:n { \cs_new_protected:Npn \@@_arg_to_keyvalue_loop_space:w } ~
+  { \@@_arg_to_keyvalue_loop:w }
+\cs_new_protected:Npn \@@_arg_to_keyvalue_loop_N_type:N #1
   {
-    \quark_if_recursion_tail_stop_do:Nn #3
-      { \tl_set:Nn \ProcessedArgument { #1 = {#2} } }
-    \str_if_eq:nnTF {#3} { = }
+    \quark_if_recursion_tail_stop_do:Nn #1
+      { \@@_arg_to_keyvalue_set_default:nn }
+    \str_if_eq:nnTF {#1} { = }
       {
         \use_i_delimit_by_q_recursion_stop:nw
-          { \tl_set:Nn \ProcessedArgument {#2} }
+          { \@@_arg_to_keyvalue_set_keyvalue:nn }
       }
       {
         \bool_lazy_or:nnTF
-            { \str_if_eq_p:nn {#3} { $ } }
-            { \str_if_eq_p:nn {#3} { \( } }
-          { \@@_arg_to_keyvalue_math:nnw {#1} {#2} }
-          { \@@_arg_to_keyvalue_loop:nnw {#1} {#2} }
+            { \str_if_eq_p:nn {#1} { $ } }
+            { \str_if_eq_p:nn {#1} { \( } }
+          { \@@_arg_to_keyvalue_math:w }
+          { \@@_arg_to_keyvalue_loop:w }
       }
   }
-\cs_new_protected:Npn \@@_arg_to_keyvalue_math:nnw
-  #1#2#3 \q_recursion_stop
+\cs_new_protected:Npn \@@_arg_to_keyvalue_math:w #1 \q_recursion_stop
   {
-    \tl_if_head_is_N_type:nTF {#3}
-      { \@@_arg_to_keyvalue_math_N_type:nnN }
+    \tl_if_head_is_N_type:nTF {#1}
+      { \@@_arg_to_keyvalue_math_N_type:N }
       {
-        \tl_if_head_is_group:nTF {#3}
-          { \@@_arg_to_keyvalue_math_group:nnn }
-          { \@@_arg_to_keyvalue_math_space:nnw }
+        \tl_if_head_is_group:nTF {#1}
+          { \@@_arg_to_keyvalue_math_group:n }
+          { \@@_arg_to_keyvalue_math_space:w }
       }
-        {#1} {#2} #3 \q_recursion_stop
+        #1 \q_recursion_stop
   }
-\cs_new_protected:Npn \@@_arg_to_keyvalue_math_N_type:nnN #1#2#3
+\cs_new_protected:Npn \@@_arg_to_keyvalue_math_N_type:N #1
   {
-    \quark_if_recursion_tail_stop_do:Nn #3
-      { \tl_set:Nn \ProcessedArgument { #1 = {#2} } }
+    \quark_if_recursion_tail_stop_do:Nn #1
+      { \@@_arg_to_keyvalue_set_default:nn }
     \bool_lazy_or:nnTF
-        { \str_if_eq_p:nn {#3} { $ } }
-        { \str_if_eq_p:nn {#3} { \) } }
-      { \@@_arg_to_keyvalue_loop:nnw {#1} {#2} }
-      { \@@_arg_to_keyvalue_math:nnw {#1} {#2} }
+        { \str_if_eq_p:nn {#1} { $ } }
+        { \str_if_eq_p:nn {#1} { \) } }
+      { \@@_arg_to_keyvalue_loop:w }
+      { \@@_arg_to_keyvalue_math:w }
   }
-\cs_new_protected:Npn \@@_arg_to_keyvalue_math_group:nnn #1#2#3
-  { \@@_arg_to_keyvalue_math:nnw {#1} {#2} }
-\cs_new_protected:Npn \@@_arg_to_keyvalue_loop_math:nnw #1#2 ~
-  { \@@_arg_to_keyvalue_math:nnw {#1} {#2} }
+\cs_new_protected:Npn \@@_arg_to_keyvalue_math_group:n #1
+  { \@@_arg_to_keyvalue_math:w }
+\use:n { \cs_new_protected:Npn \@@_arg_to_keyvalue_math_space:w } ~
+  { \@@_arg_to_keyvalue_math:w }
+\cs_new_protected:Npn \@@_arg_to_keyvalue_set_default:nn #1#2
+  { \tl_set:Nn \ProcessedArgument { #1 = {#2} } }
+\cs_new_protected:Npn \@@_arg_to_keyvalue_set_keyvalue:nn #1#2
+  { \tl_set:Nn \ProcessedArgument {#2} }
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}
@@ -4115,6 +4119,8 @@
 % \end{macro}
 % \end{macro}
 % \end{macro}
+% \end{macro}
+% \end{macro}
 %
 % \subsection{Access to the argument specification}
 %





More information about the latex3-commits mailing list.