dudleycarr/nsqjs — pull request #20 by ohwillie (2014-02-18 06:56:56+00:00)
Title: Further simplification and optimization of FrameBuffer.

Upon rereading of FrameBuffer, I noticed that the extraction of frames could be
tightened up into one simpler loop. Instead of calculating offsets and then
extracting frames, offset calculation and frame plucking are done in one loop.
Additionally, the distance from the possible next offset to the buffer end is
maintained, and if it is zero, we know that all frames have been completely
parsed from the buffer so we can intentionally lose the buffer reference so its
underlying memory is freed.

This pull request also addresses a bug introduced into frameSize by #19:
previously, we had been relying on the casting of null to zero when null was
added to a number. #19 assumed that adding undefined would have the same effect.
However, adding undefined to a number causes the result to be NaN instead being
an identity.