From 780e57d785e7b51f6045519d4565f0f831bc6a20 Mon Sep 17 00:00:00 2001 From: Bruce Miller Date: Tue, 8 Oct 2024 12:14:45 -0400 Subject: [PATCH] Simplify \lastskip,\lastkern (suggested by D.Ginev) --- lib/LaTeXML/Engine/TeX_Glue.pool.ltxml | 8 ++------ lib/LaTeXML/Engine/TeX_Kern.pool.ltxml | 8 ++------ 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/lib/LaTeXML/Engine/TeX_Glue.pool.ltxml b/lib/LaTeXML/Engine/TeX_Glue.pool.ltxml index 002e2940a..78120b1a6 100644 --- a/lib/LaTeXML/Engine/TeX_Glue.pool.ltxml +++ b/lib/LaTeXML/Engine/TeX_Glue.pool.ltxml @@ -137,12 +137,8 @@ DefPrimitiveI('\vfilneg', undef, undef); #---------------------------------------------------------------------- # \lastskip iq is 0.0 pt or the last glue or muglue on the current list. DefRegister('\lastskip' => Dimension(0), readonly => 1, getter => sub { - my $box; - for (my $i = $#LaTeXML::LIST ; $i > 0 ; $i--) { - my $box = $LaTeXML::LIST[$i]; - last if !$box || !$box->getProperty('isSkip'); - return $box->getProperty('width'); } - return Dimension(0); }); + my $box = $LaTeXML::LIST[-1]; + return ($box && $box->getProperty('isSkip') ? $box->getProperty('width') : Dimension(0)); }); #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 1; diff --git a/lib/LaTeXML/Engine/TeX_Kern.pool.ltxml b/lib/LaTeXML/Engine/TeX_Kern.pool.ltxml index 296f27811..ee308af1a 100644 --- a/lib/LaTeXML/Engine/TeX_Kern.pool.ltxml +++ b/lib/LaTeXML/Engine/TeX_Kern.pool.ltxml @@ -65,12 +65,8 @@ DefPrimitiveI('\unkern', undef, sub { # Get kern, if last on LIST DefRegister('\lastkern' => Dimension(0), readonly => 1, getter => sub { - my $box; - for (my $i = $#LaTeXML::LIST ; $i > 0 ; $i--) { - my $box = $LaTeXML::LIST[$i]; - last if !$box || !$box->getProperty('isKern'); - return $box->getProperty('width'); } - return Dimension(0); }); + my $box = $LaTeXML::LIST[-1]; + return ($box && $box->getProperty('isKern') ? $box->getProperty('width') : Dimension(0)); }); #====================================================================== # Moving Vertically