muzimuzhi / thmtools

New home for LaTeX package bundle thmtools
LaTeX Project Public License v1.3c
16 stars 3 forks source link

\thmtlo@newentry unnecessarily called twice for every theorem #48

Open mbertucci47 opened 9 months ago

mbertucci47 commented 9 months ago

In thm-listof.sty, the command \thmtlo@newentry which defines l@<theorem> is called multiple times for every theorem. Once in \thmt@mklistcmd which is added to every theorem definition:

\newcommand\thmt@mklistcmd{%
  \thmtlo@newentry
  ...
}

then

\g@addto@macro\thmt@newtheorem@predefinition{%
  \thmt@mklistcmd
  \thmt@recordenvname
}

And again for every call of \listoftheorems:

\newcommand\listoftheorems[1][]{%
...
  \@for\thmt@envname:=\thmt@allenvs\do{%
    % CHECK: is \cs{l@\thmt@envname} repeatedly defined?
    \thmtlo@newentry
  }%
...
}

And indeed, removing either the first \thmtlo@newentry above or the \@for block seems to have no effect. I guess removing the \@for block is more efficient since it leads to fewer total definitions.

Note the % CHECK: comment is in the file, not added by me.