Skip to content

Commit

Permalink
calcHash: remove unneeded h.Write() error checks
Browse files Browse the repository at this point in the history
According to the Go hash package documentation [1]:

type Hash interface {
	// Write (via the embedded io.Writer interface) adds more data to the running hash.
	// It never returns an error.
	io.Writer

[1] https://pkg.go.dev/hash#Hash
  • Loading branch information
dmaluka committed Aug 17, 2024
1 parent bc5e24b commit 5468b56
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions internal/buffer/buffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -662,22 +662,13 @@ func calcHash(b *Buffer, out *[md5.Size]byte) error {

size := 0
if len(b.lines) > 0 {
n, e := h.Write(b.lines[0].data)
if e != nil {
return e
}
n, _ := h.Write(b.lines[0].data)
size += n

for _, l := range b.lines[1:] {
n, e = h.Write([]byte{'\n'})
if e != nil {
return e
}
n, _ = h.Write([]byte{'\n'})
size += n
n, e = h.Write(l.data)
if e != nil {
return e
}
n, _ = h.Write(l.data)
size += n
}
}
Expand Down

0 comments on commit 5468b56

Please sign in to comment.