Skip to content

Commit

Permalink
Merge branch 'master' into tracing-optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
brucemiller authored Jul 3, 2023
2 parents 49da949 + 415815b commit 01e254c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ jobs:
# GitHub's CI environment comes with a preinstalled version of Strawberry Perl.
# So first uninstall that one, then pick the version we want.
run: |
cuninst -y strawberryperl
cinst -y strawberryperl --version ${{ matrix.perl }}
choco uninstall -y strawberryperl
choco install -y strawberryperl --version ${{ matrix.perl }}
# ====================
# Setup MiKTeX
Expand All @@ -89,7 +89,7 @@ jobs:
- name: Install & Configure MiKTeX
if: matrix.miktex != 'none'
run: |
cinst -y miktex --version ${{ matrix.miktex }} --params '"/Set:complete /RepoPath:""C:\miktex-repo"" /Mirror:https://mirrors.rit.edu/CTAN/systems/win32/miktex/tm/packages/"'
choco install -y miktex --version ${{ matrix.miktex }} --params '"/Set:complete /RepoPath:""C:\miktex-repo"" /Mirror:https://mirrors.rit.edu/CTAN/systems/win32/miktex/tm/packages/"'
echo "C:\Program Files\MiKTeX/miktex/bin/x64/" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
Invoke-WebRequest -Uri "https://github.com/tkw1536/execsilent/releases/download/v0.0.2/execsilent-windows-amd64.exe" -OutFile C:\execsilent.exe
Expand Down
18 changes: 7 additions & 11 deletions lib/LaTeXML/Core/Definition/Expandable.pm
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ sub new {
# rescan for match tokens and unwrap dont_expand...
$expansion = $expansion->packParameters unless $traits{nopackParameters};
}
elsif (!ref $expansion) {
$expansion = TokenizeInternal($expansion)->packParameters; }

return bless { cs => $cs, parameters => $parameters, expansion => $expansion,
locator => $source->getLocator,
isProtected => $traits{protected} || $STATE->getPrefix('protected'),
Expand All @@ -45,30 +48,23 @@ sub isExpandable {

sub getExpansion {
my ($self) = @_;
my $expansion = $$self{expansion};
if (!ref $expansion) { # Tokenization DEFERRED till actually used (shaves > 5%)
$expansion = TokenizeInternal($expansion);
# rescan for match tokens and unwrap dont_expand...
$expansion = $expansion->packParameters;
$$self{expansion} = $expansion; }
return $expansion; }
return $$self{expansion}; }

# Expand the expandable control sequence. This should be carried out by the Gullet.
sub invoke {
no warnings 'recursion';
my ($self, $gullet, $onceonly) = @_;
# shortcut for "trivial" macros; but only if not tracing & profiling!!!!
my $expansion = $self->getExpansion;
my $_tracing = $STATE->lookupValue('TRACING') || 0;
my $tracing = ($_tracing & TRACE_MACROS);
my $profiled = ($_tracing & TRACE_PROFILE) && ($LaTeXML::CURRENT_TOKEN || $$self{cs});
my $expansion = $$self{expansion};
my $etype = ref $expansion;
my $iscode = $etype eq 'CODE';
my $result;
my $parms = $$self{parameters};

LaTeXML::Core::Definition::startProfiling($profiled, 'expand') if $profiled;
if ($iscode) {
if ($etype eq 'CODE') {
# Harder to emulate \tracingmacros here.
my @args = ($parms ? $parms->readArguments($gullet, $self) : ());
$result = Tokens(&$expansion($gullet, @args));
Expand Down Expand Up @@ -113,7 +109,7 @@ sub equals {
my ($self, $other) = @_;
return (defined $other && (ref $self) eq (ref $other))
&& Equals($self->getParameters, $other->getParameters)
&& Equals($self->getExpansion, $other->getExpansion); }
&& Equals($$self{expansion}, $$other{expansion}); }

#======================================================================
1;
Expand Down
1 change: 0 additions & 1 deletion lib/LaTeXML/Package/LaTeX.pool.ltxml
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,6 @@ DefMacro('\@startsection{}{}{}{}{}{} OptionalMatch:*', sub {
else { # otherwise, just unset the flag?
$STATE->assignValue('IN_MATH' => 0, 'global'); } }
### Main logic
my $ctr = LookupValue('counter_for_' . ToString($type)) || ToString($type);
$level = ToString($level);
if ($flag) { # No number, not in TOC
(T_CS('\par'), T_CS('\@startsection@hook'), T_CS('\\@@unnumbered@section'),
Expand Down

0 comments on commit 01e254c

Please sign in to comment.