Skip to content

Use readatleast instead of reimplementing it #252

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ DisposaBoy <disposaboy at dby.me>
Frederick Mayle <frederickmayle at gmail.com>
Gustavo Kristic <gkristic at gmail.com>
Hanno Braun <mail at hannobraun.com>
Ingo Oeser <nightlyone at googlemail.com>
James Harr <james.harr at gmail.com>
Jian Zhen <zhenjl at gmail.com>
Julien Schmidt <go-sql-driver at julienschmidt.com>
Expand Down
18 changes: 3 additions & 15 deletions buffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,9 @@ func (b *buffer) fill(need int) error {

b.idx = 0

for {
n, err := b.rd.Read(b.buf[b.length:])
b.length += n

if err == nil {
if b.length < need {
continue
}
return nil
}
if b.length >= need && err == io.EOF {
return nil
}
return err
}
n, err := io.ReadAtLeast(b.rd, b.buf[b.length:], need-b.length)
b.length += n
return err
}

// returns next N bytes from buffer.
Expand Down