FAT performance improvement. In large files, seeking to a position fromt he beginning of the file can be very time consuming. ftell does lssek(fd, 0, SET_CURR). In that case, that is wasted time since we are going to seek to the same position. This fix short-circutes fat_seek() in all cases where we attempt to seek to curren position. Suggested by Nate Weibley

This commit is contained in:
Gregory Nutt 2016-08-03 13:32:52 -06:00
parent 1f9799b68d
commit 610afe9cd9

View File

@ -1054,6 +1054,18 @@ static off_t fat_seek(FAR struct file *filep, off_t offset, int whence)
return -EINVAL;
}
/* Special case: We are seeking to the current position. This would
* happen normally with ftell() which does lseek(fd, 0, SEEK_CUR) but can
* also happen in other situation such as when SEEK_SET is used to assure
* assure sequential access in a multi-threaded environment where there
* may be are multiple users to the file descriptor.
*/
if (position == filep->f_pos)
{
return OK;
}
/* Make sure that the mount is still healthy */
fat_semtake(fs);