1
0
mirror of https://github.com/golang/go synced 2024-11-23 07:10:05 -07:00

testing/fstest: optimize ReadDirFile func ReadDir

This commit is contained in:
徐志伟 2021-04-06 10:59:03 +08:00 committed by GitHub
parent 132c4fd870
commit cc9a1d5a7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -223,10 +223,7 @@ func (d *mapDir) Read(b []byte) (int, error) {
func (d *mapDir) ReadDir(count int) ([]fs.DirEntry, error) { func (d *mapDir) ReadDir(count int) ([]fs.DirEntry, error) {
n := len(d.entry) - d.offset n := len(d.entry) - d.offset
if n == 0 { if n == 0 && count > 0 {
if count <= 0 {
return nil, nil
}
return nil, io.EOF return nil, io.EOF
} }
if count > 0 && n > count { if count > 0 && n > count {