Bug 1471434 - micro-optimize refcounting for directory enumerators; r=erahm

We were not being as efficient as we could be with passing ownership.
This commit is contained in:
Nathan Froyd 2018-06-27 09:46:33 -04:00
parent befc08424b
commit 8f2baafcb6
2 changed files with 4 additions and 9 deletions

View File

@ -168,7 +168,7 @@ nsDirEnumeratorUnix::GetNext(nsISupports** aResult)
if (NS_FAILED(rv)) {
return rv;
}
NS_IF_ADDREF(*aResult = file);
file.forget(aResult);
return NS_OK;
}

View File

@ -750,7 +750,7 @@ public:
return rv;
}
mNext = do_QueryInterface(file);
mNext = file.forget();
}
*aResult = mNext != nullptr;
if (!*aResult) {
@ -768,10 +768,7 @@ public:
return rv;
}
*aResult = mNext; // might return nullptr
NS_IF_ADDREF(*aResult);
mNext = nullptr;
mNext.forget(aResult);
return NS_OK;
}
@ -783,9 +780,7 @@ public:
if (NS_FAILED(rv) || !hasMore) {
return rv;
}
*aResult = mNext;
NS_IF_ADDREF(*aResult);
mNext = nullptr;
mNext.forget(aResult);
return NS_OK;
}