5

Could the use of many unnecessary braces speed down the compilation process?

I'm asking because I use many many alert commands, defined by

\def\alert#1{\textcolor{red}{#1}}

So when I want to remove those commands usually I just delete \alert{} (TeXstudio has a shortcut to delete commands with braces: Alt+Del).

But I have to do this with the cursor on the command. So I prefer to use Find/Replace to remove only \alert and so the pair of braces still remains.

Is there some problem with the speed of compilation process if we use many unnecessary braces?

3
  • 6
    The "preferred" way would be to leave your code as-is and change the definition of \alert to \def\alert#1{#1}.
    – Werner
    Mar 10, 2013 at 15:17
  • I'm confident the speed of compilation will be comparable with a negligible difference. With modern technology this is usually the case.
    – Werner
    Mar 10, 2013 at 15:24
  • @Werner, good idea! But usually I don't delete all alert commands. After problem solved I delete it but if the point on the text is still in discussion with my partners, I keep it.
    – Sigur
    Mar 10, 2013 at 15:53

1 Answer 1

10

A brace group on its own is unlikely to make a measurable effect. foo and {foo} really are only a few extra instructions in TeX's inner loop. However what can build up to take easily observable time (and more particularly memory) is the fact that TeX has to manage local and global assignments when it gets to the } so if you have made any local assignment (definitions, font changes, \label etc) then the definitions current before the group have to be saved on a stack and restored at the end of the group. While most LaTeX environments are a group, the top level document environment gets some special handling so that it does not make a group to avoid every LaTeX command in the document being inside a group and affecting save stack usage.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .