mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1219310 - part 1 - ask the prefs file for its size directly; r=njn
Calling nsIInputStream::Available on nsIFileInputStreams is relatively expensive, as it requires three system calls: one to determine the current file position, one to seek to the end file position, and one to rewind to the previous file position. We can do better by asking the file for its size directly, prior to opening the stream. This only requires one system call, stat, and is thus superior--at least in considering the number of system calls.
This commit is contained in:
parent
9c8cb321ef
commit
8ecc1d6489
@ -1000,8 +1000,8 @@ static nsresult openPrefFile(nsIFile* aFile)
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
uint64_t fileSize64;
|
||||
rv = inStr->Available(&fileSize64);
|
||||
int64_t fileSize64;
|
||||
rv = aFile->GetFileSize(&fileSize64);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
NS_ENSURE_TRUE(fileSize64 <= UINT32_MAX, NS_ERROR_FILE_TOO_BIG);
|
||||
|
Loading…
Reference in New Issue
Block a user