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:
parent
132c4fd870
commit
cc9a1d5a7e
@ -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 {
|
||||||
|
Loading…
Reference in New Issue
Block a user