Bug 1642951 - Don't open the underlying file unnecessarily when seeking nsFileInputStream to the start. r=baku,necko-reviewers,valentin

Differential Revision: https://phabricator.services.mozilla.com/D91088
This commit is contained in:
Matt Woodrow 2020-09-23 23:34:19 +00:00
Родитель 413b79889f
Коммит e0be63cf32
1 изменённых файлов: 6 добавлений и 0 удалений

Просмотреть файл

@ -522,6 +522,12 @@ nsresult nsFileInputStream::SeekInternal(int32_t aWhence, int64_t aOffset,
aWhence = NS_SEEK_SET;
aOffset += mCachedPosition;
}
// If we're trying to seek to the start then we're done, so
// return early to avoid Seek from calling DoPendingOpen and
// opening the underlying file earlier than necessary.
if (aWhence == NS_SEEK_SET && aOffset == 0) {
return NS_OK;
}
} else {
return NS_BASE_STREAM_CLOSED;
}