facebook/tornado — pull request #479 by alekstorm (2012-03-15 22:04:49+00:00)
Title: Refactor IOStream.read_from_buffer() for speed, clarity

Just a straightforward refactoring of IOStream.read_from_buffer(). The new version is cleaner, shorter, easier to read, and has less code duplication. There are a couple fewer condition checks, but no speedups by an order of magnitude. All tests pass.

Highlights:
- Loops were restructured to get rid of initial and final checks
- Duplicated buffer chunk size-doubling code factored out into `_double_prefix` function
- The `streaming_callback` is now called from only one place