Skip to content

Commit

Permalink
* simplifications (comments golang#150, golang#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
bsponge committed Sep 30, 2023
1 parent 2fa6c8e commit 5b9bb80
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions txtar/archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,11 @@ func isMarker(data []byte) (name string, lineSeparator, after []byte) {
// lineSeparator states if \n or \r\n should be appended as a line separator if it is not present.
// Otherwise fixNL returns a new slice consisting of data with a final lineSeparator added.
func fixNL(data , lineSeparator []byte) []byte {
if len(data) == 0 || bytes.HasSuffix(data, lf) || bytes.HasSuffix(data, crlf) {
if len(data) == 0 || bytes.HasSuffix(data, lf) {
return data
}
d := make([]byte, len(data)+len(lineSeparator))
copy(d, data)
copy(d[len(d)-len(lineSeparator):], lineSeparator)
copy(d[len(data):], lineSeparator)
return d
}

0 comments on commit 5b9bb80

Please sign in to comment.