ajaxorg/cloud9 — pull request #633 by sergi (2011-12-08 13:57:44+00:00)
Title: The console should have a limited output buffer

This patch solves the problem that arises when storing unlimited DOM nodes in
the console output. Every line in the output buffer is an extra DOM node,
sometimes with other nodes nested within. Of course, that is very expensive
memory-wise. The problem is easily visible by executing a shell command that
yields many lines of output (such as `ls -R`, for example).

This patch avoids the console from even writing that many elements in the console.
After receiving the internal output from the shell command, the `Logger` now only
takes the last `n` lines, where `n` is determined by `MAX_LINES` (currently set
at 255).

If the currently streamed output has already more than `MAX_LINES` lines, the
console contents are wiped out, and the output properly trimmed. Otherwise, we
make sure that the incoming output plus the existing buffer output don't add up to
more than `MAX_LINES`, and if they do, we trim it properly.

This results in a considerable speedup (try `ls -R` at the root of a big folder
with and without the patch to test).

Other small optimizations have gone into the patch.

To be reviewed by @fjakobs @zefhemel @janjongboom