At this line in stream-read-sequence, you're doing (subseq buffer start <end>), but start is an index into the output sequence, not an index into the internal stream buffer. This causes problems when trying to fill a large sequence from multiple reads on a tcp connection.
This branch fixes that and cleans the function up a little. There should be a small performance increase, since the new version doesn't cons up an intermediate sequence to copy into the output. You could get more out of it by storing a read cursor in the stream instead of using subseq on the internal buffer, but that's a bit more involved.
At this line in stream-read-sequence, you're doing
(subseq buffer start <end>)
, butstart
is an index into the output sequence, not an index into the internal stream buffer. This causes problems when trying to fill a large sequence from multiple reads on a tcp connection.This branch fixes that and cleans the function up a little. There should be a small performance increase, since the new version doesn't cons up an intermediate sequence to copy into the output. You could get more out of it by storing a read cursor in the stream instead of using
subseq
on the internal buffer, but that's a bit more involved.