forked from TrueCloudLab/distribution
Avoid unnecessary type assertion in mfs driver
We already make sure the node in *dir Signed-off-by: Milos Gajdos <milosthegajdos@gmail.com>
This commit is contained in:
parent
59fd8656ac
commit
a9d31ec7b9
1 changed files with 5 additions and 7 deletions
|
@ -1,7 +1,6 @@
|
||||||
package inmemory
|
package inmemory
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"path"
|
"path"
|
||||||
|
@ -98,13 +97,12 @@ func (d *dir) list(p string) ([]string, error) {
|
||||||
return nil, errIsNotDir
|
return nil, errIsNotDir
|
||||||
}
|
}
|
||||||
|
|
||||||
dir, ok := n.(*dir)
|
// NOTE(milosgajdos): this is safe to do because
|
||||||
if !ok {
|
// n can only be *dir due to the compile time check
|
||||||
return nil, errors.New("not a directory")
|
dirChildren := n.(*dir).children
|
||||||
}
|
|
||||||
|
|
||||||
children := make([]string, 0, len(dir.children))
|
children := make([]string, 0, len(dirChildren))
|
||||||
for _, child := range dir.children {
|
for _, child := range dirChildren {
|
||||||
children = append(children, child.path())
|
children = append(children, child.path())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue