Skip to content

Commit 2f3fda1

Browse files
committed
mountinfo: GetMountsFromReader() remove redundant switch
This switch was implementing the exact same check as is done in strings.Join(); https://cs.opensource.google/go/go/+/refs/tags/go1.16.7:src/strings/strings.go;l=421-427 This only difference removing this switch makes is that it will assign an empty string to p.Optional if no optional fields are present, but given that an empty string is the default value for p.Optional, this should make no difference. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent f3885c8 commit 2f3fda1

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

mountinfo/mountinfo_linux.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,16 +105,9 @@ func GetMountsFromReader(r io.Reader, filter FilterFunc) ([]*Info, error) {
105105
p.Options = fields[5]
106106

107107
// zero or more optional fields
108-
switch {
109-
case sepIdx == 6:
110-
// zero, do nothing
111-
case sepIdx == 7:
112-
p.Optional = fields[6]
113-
default:
114-
p.Optional = strings.Join(fields[6:sepIdx-1], " ")
115-
}
108+
p.Optional = strings.Join(fields[6:sepIdx-1], " ")
116109

117-
// Run the filter after parsing all of the fields.
110+
// Run the filter after parsing all fields.
118111
var skip, stop bool
119112
if filter != nil {
120113
skip, stop = filter(p)

0 commit comments

Comments
 (0)