From b145b7ca59612035286081de6cb1e6dc06595e7b Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sun, 21 Jul 2024 13:55:52 +0200 Subject: [PATCH] mountinfo: GetMountsFromReader: inline some assignments Signed-off-by: Sebastiaan van Stijn --- mountinfo/mountinfo_linux.go | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/mountinfo/mountinfo_linux.go b/mountinfo/mountinfo_linux.go index 3667781..43ced2c 100644 --- a/mountinfo/mountinfo_linux.go +++ b/mountinfo/mountinfo_linux.go @@ -81,10 +81,13 @@ func GetMountsFromReader(r io.Reader, filter FilterFunc) ([]*Info, error) { } p := &Info{ - ID: toInt(fields[0]), - Parent: toInt(fields[1]), - Major: toInt(major), - Minor: toInt(minor), + ID: toInt(fields[0]), + Parent: toInt(fields[1]), + Major: toInt(major), + Minor: toInt(minor), + Options: fields[5], + Optional: strings.Join(fields[6:sepIdx], " "), // zero or more optional fields + VFSOptions: fields[sepIdx+3], } p.Mountpoint, err = unescape(fields[4]) @@ -99,18 +102,12 @@ func GetMountsFromReader(r io.Reader, filter FilterFunc) ([]*Info, error) { if err != nil { return nil, fmt.Errorf("parsing '%s' failed: source: %w", fields[sepIdx+2], err) } - p.VFSOptions = fields[sepIdx+3] p.Root, err = unescape(fields[3]) if err != nil { return nil, fmt.Errorf("parsing '%s' failed: root: %w", fields[3], err) } - p.Options = fields[5] - - // zero or more optional fields - p.Optional = strings.Join(fields[6:sepIdx], " ") - // Run the filter after parsing all fields. var skip, stop bool if filter != nil {