Skip to content

Block transform stores more data than needed #11

@martinholters

Description

@martinholters

Consider

const remain = blockSize + ((data.length % blockSize) || blockSize);
const align = data.length > remain ? data.length - remain : 0;

Here remain is the amount of data to store and combine with the next chunk once it arrives, and align is the amount of data to process in this _transform call. I don't see why it should ever be necessary to store more than one blockSize for later. Doesn't it suffice to do

 const remain = data.length % blockSize;     
 const align = data.length - remain; 

? Not that the current code is wrong - after the final flush, everything sorts out - but it adds unnecessary latency which may prevent this from working in a duplex communication scenario. (I.e. I'm waiting to receive an answer to my last request before sending the next request, but my last request or the last answer are "stuck" in the transform.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions