mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Bug 1219310 - part 2 - keep track of how much pref file we have read; r=njn
Looking at a preference file read with strace typically looks like: open("...", O_RDONLY) = X ... read(X, "...", SIZE) = SIZE read(X, "...", SIZE) = 0 ... There's no reason to call Read() and make another syscall to determine there's no data left for reading. We can keep track of how much we've read at minimal cost and thus determine for ourselves when we are done.
This commit is contained in:
parent
17b7d5be31
commit
65fd1f7783
@ -1017,6 +1017,7 @@ static nsresult openPrefFile(nsIFile* aFile)
|
||||
// Read is not guaranteed to return a buf the size of fileSize,
|
||||
// but usually will.
|
||||
nsresult rv2 = NS_OK;
|
||||
uint32_t offset = 0;
|
||||
for (;;) {
|
||||
uint32_t amtRead = 0;
|
||||
rv = inStr->Read((char*)fileBuffer, fileSize, &amtRead);
|
||||
@ -1024,6 +1025,10 @@ static nsresult openPrefFile(nsIFile* aFile)
|
||||
break;
|
||||
if (!PREF_ParseBuf(&ps, fileBuffer, amtRead))
|
||||
rv2 = NS_ERROR_FILE_CORRUPTED;
|
||||
offset += amtRead;
|
||||
if (offset == fileSize) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
PREF_FinalizeParseState(&ps);
|
||||
|
Loading…
Reference in New Issue
Block a user