mozilla/pdf.js — pull request #4382 by nnethercote (2014-03-04 01:27:20+00:00)
Title: Avoid extra allocations in ensureBuffer() caused by an off-by-one error.

If you call ensureBuffer() with a |requested| value equal to the current |buffer.byteLength|, it'll allocate a new buffer that's the same size as the current one, due to a simple off-by-one error.

And this actually does manifest in practice -- there are a non-trivial number of redundant reallocations of this kind. In one large document, this change saves 3.4 MiB of unnecessary re-allocations. This wasn't enough to noticeably change the peak RSS requirements, but still! :)