[latex3-commits] [latex3/latex2e] gh1189: Use a marker for optimised cmds (aabb573a)
github at latex-project.org
github at latex-project.org
Tue Nov 28 17:50:55 CET 2023
Repository : https://github.com/latex3/latex2e
On branch : gh1189
Link : https://github.com/latex3/latex2e/commit/aabb573ac82d576d10f3e0e77965184368f09294
>---------------------------------------------------------------
commit aabb573ac82d576d10f3e0e77965184368f09294
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date: Tue Nov 28 16:48:36 2023 +0000
Use a marker for optimised cmds
>---------------------------------------------------------------
aabb573ac82d576d10f3e0e77965184368f09294
base/ltcmd.dtx | 24 ++++--------
base/testfiles-ltcmd/github-1009.tlg | 16 ++++----
base/testfiles-ltcmd/ltcmd001.tlg | 63 +++++++++++++++++---------------
base/testfiles-ltcmd/ltcmd002.luatex.tlg | 2 +-
base/testfiles-ltcmd/ltcmd002.tlg | 2 +-
5 files changed, 50 insertions(+), 57 deletions(-)
diff --git a/base/ltcmd.dtx b/base/ltcmd.dtx
index 1b92e601..ab9a129f 100644
--- a/base/ltcmd.dtx
+++ b/base/ltcmd.dtx
@@ -442,11 +442,7 @@
% \@@_declare_cmd_code_aux:Nnn,
% \@@_declare_cmd_code_expandable:Nnn
% }
-% \begin{macro}
-% {
-% \@@_declare_cmd_optimised:NNNn,
-% \@@_declare_cmd_optimised:NcNn
-% }
+% \begin{macro}{\@@_start_optimised:}
% \changes{v1.2b}{2023/11/28}
% {Optimise cmd creation for all-\texttt{m} arguments}
% At this stage we can check for a short-cut possibility: if the signature
@@ -475,23 +471,17 @@
}
% \end{macrocode}
% The optimised version of commands just has to worry about whether to make
-% them protected. We retain one level of indirection so it is still clear
-% these are \pkg{ltcmd}-derived.
+% them protected. The commands start with an expandable marker so that other
+% parts of the kernel know these are set up by \pkg{ltcmd}
% \begin{macrocode}
\cs_new_protected:Npn \@@_declare_cmd_optimised:Nnn #1#2#3
{
\bool_if:NTF \l_@@_expandable_bool
- { \@@_declare_cmd_optimised:NcNn \cs_set_nopar:Npn }
- { \@@_declare_cmd_optimised:NcNn \cs_set_protected_nopar:Npn }
- { \l_@@_function_tl \c_space_tl code } #1 {#3}
- }
-\cs_new_protected:Npn \@@_declare_cmd_optimised:NNNn #1#2#3#4
- {
- #1 #3 {#2}
- \cs_generate_from_arg_count:NNnn #2 #1
- \l_@@_current_arg_int {#4}
+ { \cs_generate_from_arg_count:NNnn #1 \cs_set_nopar:Npn }
+ { \cs_generate_from_arg_count:NNnn #1 \cs_set_protected_nopar:Npn }
+ \l_@@_current_arg_int { \@@_start_optimised: #3 }
}
-\cs_generate_variant:Nn \@@_declare_cmd_optimised:NNNn { Nc }
+\cs_new:Npn \@@_start_optimised: { }
% \end{macrocode}
% Standard functions call \cs{@@_start:nNNnnn}, which receives the
% argument specification, an auxiliary used for
diff --git a/base/testfiles-ltcmd/github-1009.tlg b/base/testfiles-ltcmd/github-1009.tlg
index 7640ca94..67965ea5 100644
--- a/base/testfiles-ltcmd/github-1009.tlg
+++ b/base/testfiles-ltcmd/github-1009.tlg
@@ -4,19 +4,19 @@ Don't change this file in any respect.
TEST 1: Non-expandable Document Commands with m-type arguments
============================================================
> \foo=\protected macro:
-->\foo code .
+->\__cmd_start_optimised: .
<argument> \foo
l. ...}
> \baz=\protected macro:
-->\foo code .
+->\__cmd_start_optimised: .
<argument> \baz
l. ...}
> \foo=\protected macro:
-->\foo code .
+#1->\__cmd_start_optimised: .
<argument> \foo
l. ...}
> \baz=\protected macro:
-->\foo code .
+#1->\__cmd_start_optimised: .
<argument> \baz
l. ...}
> \foo=document command:
@@ -44,19 +44,19 @@ l. ...}
TEST 2: Expandable Document Commands with m-type arguments
============================================================
> \foo=macro:
-->\foo code .
+->\__cmd_start_optimised: .
<argument> \foo
l. ...}
> \baz=macro:
-->\foo code .
+->\__cmd_start_optimised: .
<argument> \baz
l. ...}
> \foo=macro:
-->\foo code .
+#1->\__cmd_start_optimised: .
<argument> \foo
l. ...}
> \baz=macro:
-->\foo code .
+#1->\__cmd_start_optimised: .
<argument> \baz
l. ...}
> \foo=expandable document command:
diff --git a/base/testfiles-ltcmd/ltcmd001.tlg b/base/testfiles-ltcmd/ltcmd001.tlg
index 0b834e99..517d0a8a 100644
--- a/base/testfiles-ltcmd/ltcmd001.tlg
+++ b/base/testfiles-ltcmd/ltcmd001.tlg
@@ -17,70 +17,73 @@ For immediate help type H <return>.
l. ...}
You have used \RenewDocumentCommand with a command that was never defined.
LaTeX will ignore this entire definition.
-> \foo=\protected macro:->\foo code .
+> \foo=\protected macro:->\__cmd_start_optimised: First definition.
<recently read> }
l. ...}
-> \foo code=\protected macro:->First definition.
+> \foo code=undefined.
<recently read> }
l. ...}
============================================================
============================================================
TEST 2: Commands with simple mandatory arguments
============================================================
-> \foo=\protected macro:->\foo code .
+> \foo=\protected macro:#1->\__cmd_start_optimised: (#1).
<recently read> }
l. ...}
-> \foo code=\protected macro:#1->(#1).
+> \foo code=undefined.
<recently read> }
l. ...}
-> \foo=\protected macro:->\foo code .
+> \foo=\protected macro:#1#2->\__cmd_start_optimised: (#1)(#2).
<recently read> }
l. ...}
-> \foo code=\protected macro:#1#2->(#1)(#2).
+> \foo code=undefined.
<recently read> }
l. ...}
-> \foo=\protected macro:->\foo code .
+> \foo=\protected macro:#1#2#3->\__cmd_start_optimised: (#1)(#2)(#3).
<recently read> }
l. ...}
-> \foo code=\protected macro:#1#2#3->(#1)(#2)(#3).
+> \foo code=undefined.
<recently read> }
l. ...}
-> \foo=\protected macro:->\foo code .
+> \foo=\protected macro:#1#2#3#4->\__cmd_start_optimised: (#1)(#2)(#3)(#4).
<recently read> }
l. ...}
-> \foo code=\protected macro:#1#2#3#4->(#1)(#2)(#3)(#4).
+> \foo code=undefined.
<recently read> }
l. ...}
-> \foo=\protected macro:->\foo code .
+> \foo=\protected macro:#1#2#3#4#5->\__cmd_start_optimised:
+(#1)(#2)(#3)(#4)(#5).
<recently read> }
l. ...}
-> \foo code=\protected macro:#1#2#3#4#5->(#1)(#2)(#3)(#4)(#5).
+> \foo code=undefined.
<recently read> }
l. ...}
-> \foo=\protected macro:->\foo code .
+> \foo=\protected macro:#1#2#3#4#5#6->\__cmd_start_optimised:
+(#1)(#2)(#3)(#4)(#5)(#6).
<recently read> }
l. ...}
-> \foo code=\protected macro:#1#2#3#4#5#6->(#1)(#2)(#3)(#4)(#5)(#6).
+> \foo code=undefined.
<recently read> }
l. ...}
-> \foo=\protected macro:->\foo code .
+> \foo=\protected macro:#1#2#3#4#5#6#7->\__cmd_start_optimised:
+(#1)(#2)(#3)(#4)(#5)(#6)(#7).
<recently read> }
l. ...}
-> \foo code=\protected macro:#1#2#3#4#5#6#7->(#1)(#2)(#3)(#4)(#5)(#6)(#7).
+> \foo code=undefined.
<recently read> }
l. ...}
-> \foo=\protected macro:->\foo code .
+> \foo=\protected macro:#1#2#3#4#5#6#7#8->\__cmd_start_optimised:
+(#1)(#2)(#3)(#4)(#5)(#6)(#7)(#8).
<recently read> }
l. ...}
-> \foo code=\protected
-macro:#1#2#3#4#5#6#7#8->(#1)(#2)(#3)(#4)(#5)(#6)(#7)(#8).
+> \foo code=undefined.
<recently read> }
l. ...}
-> \foo=\protected macro:->\foo code .
+> \foo=\protected macro:#1#2#3#4#5#6#7#8#9->\__cmd_start_optimised:
+(#1)(#2)(#3)(#4)(#5)(#6)(#7)(#8)(#9).
<recently read> }
l. ...}
-> \foo code=\protected
-macro:#1#2#3#4#5#6#7#8#9->(#1)(#2)(#3)(#4)(#5)(#6)(#7)(#8)(#9).
+> \foo code=undefined.
<recently read> }
l. ...}
============================================================
@@ -322,10 +325,10 @@ l. ...}
============================================================
TEST 8: Some valid expandable functions
============================================================
-> \foo=macro:->\foo code .
+> \foo=macro:#1->\__cmd_start_optimised: (#1).
<recently read> }
l. ...}
-> \foo code=macro:#1->(#1).
+> \foo code=undefined.
<recently read> }
l. ...}
> \foo=macro:->\__cmd_start_expandable:nNNNNn {+m}\foo \foo \foo code
@@ -335,10 +338,10 @@ l. ...}
> \foo code=\long macro:#1->(#1).
<recently read> }
l. ...}
-> \foo=macro:->\foo code .
+> \foo=macro:#1#2#3->\__cmd_start_optimised: (#1)(#2)(#3).
<recently read> }
l. ...}
-> \foo code=macro:#1#2#3->(#1)(#2)(#3).
+> \foo code=\long macro:#1->(#1).
<recently read> }
l. ...}
> \foo=macro:->\__cmd_start_expandable:nNNNNn {om}\foo \foo \foo code
@@ -438,10 +441,10 @@ l. ...}
You have used \RenewDocumentEnvironment with an environment that was never
defined.
LaTeX will ignore this entire definition.
-> \environment foo=\protected macro:->\environment foo code .
+> \environment foo=\protected macro:->\__cmd_start_env:nnnnn {}{foo}{}{}{}.
<recently read> }
l. ...}
-> \environment foo code=\protected macro:->First.
+> \environment foo code=\protected\long macro:->First.
<recently read> }
l. ...}
============================================================
@@ -696,10 +699,10 @@ l. ...}
You have used \RenewExpandableDocumentCommand with a command that was never
defined.
LaTeX will ignore this entire definition.
-> \foo=macro:->\foo code .
+> \foo=macro:->\__cmd_start_optimised: First definition.
<recently read> }
l. ...}
-> \foo code=macro:->First definition.
+> \foo code=undefined.
<recently read> }
l. ...}
============================================================
diff --git a/base/testfiles-ltcmd/ltcmd002.luatex.tlg b/base/testfiles-ltcmd/ltcmd002.luatex.tlg
index 39a66403..62d4d73c 100644
--- a/base/testfiles-ltcmd/ltcmd002.luatex.tlg
+++ b/base/testfiles-ltcmd/ltcmd002.luatex.tlg
@@ -48,7 +48,7 @@ TEST 2: Nesting optional arguments
TEST 3: Invalid arguments (types s, o m)
============================================================
Runaway argument?
-! Paragraph ended before \foo code was complete.
+! Paragraph ended before \foo was complete.
<to be read again>
\par
l. ...}
diff --git a/base/testfiles-ltcmd/ltcmd002.tlg b/base/testfiles-ltcmd/ltcmd002.tlg
index cad76a7b..3a5fbeb9 100644
--- a/base/testfiles-ltcmd/ltcmd002.tlg
+++ b/base/testfiles-ltcmd/ltcmd002.tlg
@@ -48,7 +48,7 @@ TEST 2: Nesting optional arguments
TEST 3: Invalid arguments (types s, o m)
============================================================
Runaway argument?
-! Paragraph ended before \foo code was complete.
+! Paragraph ended before \foo was complete.
<to be read again>
\par
l. ...}
More information about the latex3-commits
mailing list.