Make Process#communicate do less work on every iteration (#69)
Make Process#communicate do less work on every iteration (#69)

* Make Process#communicate do less work on every iteration

Authored-by @synfo-stripe

    Without this change communicating 700MB worth of data to 'cat' takes
    ~1h, with it it's closer to 1s.

    My hypothesis is that `input[0...written] = ''` causes ruby to either
    allocate a whole new string buffer, or at the very least rewrite the
    entirety of the existing buffer, whereas `input = input[written..]` lets
    ruby use shared string optimization and only create a new RString
    pointing to the same buffer.

* Don't use endless range

Co-authored-by: Jake Zimmerman <55b204b65def233ad0bf20a8c16f1b6084a2e61c@gmail.com>
stripe/subprocess,stripe/subprocess