| 1 |
% $Id: locnull-optimize.ch 70150 2024-02-25 17:08:15Z karl $ |
| 2 |
% (public domain) |
| 3 |
% |
| 4 |
% Date: Wed, 21 Feb 2024 21:32:57 +0000 (UTC) |
| 5 |
% From: David Fuchs <[email protected]> |
| 6 |
% To: Karl Berry <[email protected]> |
| 7 |
% Subject: Missed optimization in TeX: |loc=null| implies |state=token_list| |
| 8 |
% |
| 9 |
% The final comment in <Recover from an unbalanced output routine> |
| 10 |
% explicitly notes that |null=min_halfword<=0|, and it assumes we |
| 11 |
% also know that during file input, |loc| can only be as small as |
| 12 |
% the initial value of |first|, which is 1. So |loc| |
| 13 |
% is strictly larger than |null| during file input (i.e. when |
| 14 |
% |state<>token_list|). |
| 15 |
% |
| 16 |
% So, |loc=null| implies |state=token_list|. |
| 17 |
% Thus, |(state=token_list)and(loc=null) = (loc=null)| always. |
| 18 |
% |
| 19 |
% Ergo, we can simplify two statements in TeX (two cases of "conserve |
| 20 |
% stack space", the first of which is inner-loop; might save a whole cycle). |
| 21 |
% |
| 22 |
% In |back_input|: |
| 23 |
@x [23.325] l.7025 |
| 24 |
begin while (state=token_list)and(loc=null)and(token_type<>v_template) do |
| 25 |
@y |
| 26 |
begin while (loc=null)and(token_type<>v_template) do |
| 27 |
@z |
| 28 |
|
| 29 |
% In <Feed the macro body and its parameters to the scanner>: |
| 30 |
@x [25.390] l.7983 |
| 31 |
while (state=token_list)and(loc=null)and(token_type<>v_template) do |
| 32 |
@y |
| 33 |
while (loc=null)and(token_type<>v_template) do |
| 34 |
@z |