mirror of
https://github.com/protocolbuffers/protobuf-go.git
synced 2025-01-01 11:58:21 +00:00
internal/encoding/text: minor tweak in inserting random whitespace
Simply move logic into similar code block. Maintains the same logic. Change-Id: I7b5a3f3d57f6102c7919cdc03dd105f08d21aca3 Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/194039 Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
This commit is contained in:
parent
09217f08d2
commit
4eb4d61b0c
@ -113,11 +113,11 @@ func (p *encoder) marshalMessage(v Value, emitDelims bool) error {
|
||||
p.out = append(p.out, ':')
|
||||
if len(p.indent) > 0 {
|
||||
p.out = append(p.out, ' ')
|
||||
}
|
||||
// For multi-line output, add a random extra space after key: per message to
|
||||
// make output unstable.
|
||||
if len(p.indent) > 0 && detrand.Bool() {
|
||||
p.out = append(p.out, ' ')
|
||||
// For multi-line output, add a random extra space after key:
|
||||
// to make output unstable.
|
||||
if detrand.Bool() {
|
||||
p.out = append(p.out, ' ')
|
||||
}
|
||||
}
|
||||
|
||||
if err := p.marshalValue(item[1]); err != nil {
|
||||
@ -125,11 +125,11 @@ func (p *encoder) marshalMessage(v Value, emitDelims bool) error {
|
||||
}
|
||||
if i < len(items)-1 && len(p.indent) == 0 {
|
||||
p.out = append(p.out, ' ')
|
||||
}
|
||||
// For single-line output, add a random extra space after a field per message to
|
||||
// make output unstable.
|
||||
if len(p.indent) == 0 && detrand.Bool() && i != len(items)-1 {
|
||||
p.out = append(p.out, ' ')
|
||||
// For single-line output, add a random extra space after a field
|
||||
// to make output unstable.
|
||||
if detrand.Bool() {
|
||||
p.out = append(p.out, ' ')
|
||||
}
|
||||
}
|
||||
p.out = append(p.out, p.newline...)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user