Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
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 '13 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 '13 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 '13 at 15:53

1 Answer 1

up vote 10 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.