I'd like to write some lightning-fast functions for analyzing LaTeX code. Because they could involve a lot of complicated processing of large documents, I don't know whether it's a good idea to write them completely in Lisp or not. How fast is byte-compiled Lisp compared to C, and how intensive does the processing have to be for the user to notice a difference?
Specifically, I'm trying to implement better functions for finding certain types of errors -- for example, neither show-paren-mode nor smartparens-latex are smart enough to notice that \left and \right are brackets that must match with another \left or \right. These programs also don't know that there are features brackets can't match across (so if it encounters one of these features, which will have to be defined a complicated way since it's environment-dependent), it should report a paren mismatch.
Because of the potential complexity of the code (parsing LaTeX can depend on the environment in complicated ways) and the fact that it has to be fast enough that the user won't notice a delay when, for example, they move the cursor over a parenthesis, I'm concerned about optimizing the code, and I want to know whether I can get away with writing careful Lisp or if it would be smarter to implement one or more primitives to help with the grunt-work.