Skip to content

Prevent double buffering by exposing the BufRead bound#100

Merged
mdecimus merged 1 commit intostalwartlabs:mainfrom
sftse:iobuffering
Feb 9, 2025
Merged

Prevent double buffering by exposing the BufRead bound#100
mdecimus merged 1 commit intostalwartlabs:mainfrom
sftse:iobuffering

Conversation

@sftse
Copy link
Copy Markdown
Contributor

@sftse sftse commented Feb 7, 2025

This is a bit of a nit, but interfaces that expose Read bounds should not do internal buffering, as this risks the caller accidentally passing a type that is already buffered, resulting in double buffering. Instead, by exposing the BufRead bound the caller is forced to buffer if he tries passing a type that only implements Read. Since the caller has better awareness of the code he is writing, he is much less likely to accidentally buffer a reader twice.

@mdecimus mdecimus merged commit 209778f into stalwartlabs:main Feb 9, 2025
1 check passed
@sftse sftse deleted the iobuffering branch November 6, 2025 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants