Bug 1317954 - Use auto type specifier where aplicable for variable declarations to improve code readability and maintainability in xpcom/. r=froydnj

MozReview-Commit-ID: EZZrYF1W81B

--HG--
extra : rebase_source : 30eea607d07ac819a0e55a2c4b0f8c359c156705
This commit is contained in:
Andi-Bogdan Postelnicu 2016-11-16 14:24:59 +02:00
Родитель d7f83a7ea6
Коммит 42effb5bbf
9 изменённых файлов: 22 добавлений и 23 удалений

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

@ -113,8 +113,7 @@ BaseStringEnumerator::GetNext(nsISupports** aResult)
return NS_ERROR_FAILURE;
}
nsSupportsDependentCString* str =
new nsSupportsDependentCString(mArray[mSimpleCurItem++]);
auto* str = new nsSupportsDependentCString(mArray[mSimpleCurItem++]);
if (!str) {
return NS_ERROR_OUT_OF_MEMORY;
}
@ -173,7 +172,7 @@ public:
EntryEnumerator*
EntryEnumerator::Create(nsTHashtable<CategoryLeaf>& aTable)
{
EntryEnumerator* enumObj = new EntryEnumerator();
auto* enumObj = new EntryEnumerator();
if (!enumObj) {
return nullptr;
}
@ -337,7 +336,7 @@ CategoryEnumerator*
CategoryEnumerator::Create(nsClassHashtable<nsDepCharHashKey, CategoryNode>&
aTable)
{
CategoryEnumerator* enumObj = new CategoryEnumerator();
auto* enumObj = new CategoryEnumerator();
if (!enumObj) {
return nullptr;
}

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

@ -721,7 +721,7 @@ nsComponentManagerImpl::ManifestComponent(ManifestProcessingContext& aCx,
*permanentCID = cid;
PL_ARENA_ALLOCATE(place, &mArena, sizeof(mozilla::Module::CIDEntry));
mozilla::Module::CIDEntry* e = new (place) mozilla::Module::CIDEntry();
auto* e = new (place) mozilla::Module::CIDEntry();
e->cid = permanentCID;
f = new nsFactoryEntry(e, km);
@ -1691,7 +1691,7 @@ nsComponentManagerImpl::EnumerateCIDs(nsISimpleEnumerator** aEnumerator)
NS_IMETHODIMP
nsComponentManagerImpl::EnumerateContractIDs(nsISimpleEnumerator** aEnumerator)
{
nsTArray<nsCString>* array = new nsTArray<nsCString>;
auto* array = new nsTArray<nsCString>;
for (auto iter = mContractIDs.Iter(); !iter.Done(); iter.Next()) {
const nsACString& contract = iter.Key();
array->AppendElement(contract);
@ -1803,8 +1803,8 @@ nsFactoryEntry::nsFactoryEntry(const nsCID& aCID, nsIFactory* aFactory)
, mModule(nullptr)
, mFactory(aFactory)
{
mozilla::Module::CIDEntry* e = new mozilla::Module::CIDEntry();
nsCID* cid = new nsCID;
auto* e = new mozilla::Module::CIDEntry();
auto* cid = new nsCID;
*cid = aCID;
e->cid = cid;
mCIDEntry = e;

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

@ -279,8 +279,8 @@ NS_NewUnionEnumerator(nsISimpleEnumerator** aResult,
} else if (!aSecondEnumerator) {
*aResult = aFirstEnumerator;
} else {
nsUnionEnumerator* enumer = new nsUnionEnumerator(aFirstEnumerator,
aSecondEnumerator);
auto* enumer = new nsUnionEnumerator(aFirstEnumerator,
aSecondEnumerator);
if (!enumer) {
return NS_ERROR_OUT_OF_MEMORY;
}

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

@ -26,7 +26,7 @@ InvalidArrayIndex_CRASH(size_t aIndex, size_t aLength)
// Leak the buffer on the heap to make sure that it lives long enough, as
// MOZ_CRASH_ANNOTATE expects the pointer passed to it to live to the end of
// the program.
char* buffer = new char[CAPACITY];
auto* buffer = new char[CAPACITY];
snprintf(buffer, CAPACITY,
"ElementAt(aIndex = %llu, aLength = %llu)",
(long long unsigned) aIndex,

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

@ -134,7 +134,7 @@ static DependentLib* sTop;
static void
AppendDependentLib(LibHandleType aLibHandle)
{
DependentLib* d = new DependentLib;
auto* d = new DependentLib;
if (!d) {
return;
}

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

@ -827,7 +827,7 @@ nsLocalFile::CopyToNative(nsIFile* aNewParent, const nsACString& aNewName)
#endif
// actually create the file.
nsLocalFile* newFile = new nsLocalFile();
auto* newFile = new nsLocalFile();
nsCOMPtr<nsIFile> fileRef(newFile); // release on exit
rv = newFile->InitWithNativePath(newPathName);
@ -1040,7 +1040,7 @@ nsLocalFile::Remove(bool aRecursive)
}
if (aRecursive) {
nsDirEnumeratorUnix* dir = new nsDirEnumeratorUnix();
auto* dir = new nsDirEnumeratorUnix();
nsCOMPtr<nsISimpleEnumerator> dirRef(dir); // release on exit

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

@ -102,7 +102,7 @@ nsresult
CreateIFoo( void** result )
// a typical factory function (that calls AddRef)
{
IFoo* foop = new IFoo;
auto* foop = new IFoo;
foop->AddRef();
*result = foop;
@ -190,7 +190,7 @@ nsresult
CreateIBar( void** result )
// a typical factory function (that calls AddRef)
{
IBar* barp = new IBar;
auto* barp = new IBar;
barp->AddRef();
*result = barp;
@ -332,10 +332,10 @@ void Comparison()
void DontAddRef()
{
{
IFoo* raw_foo1p = new IFoo;
auto* raw_foo1p = new IFoo;
raw_foo1p->AddRef();
IFoo* raw_foo2p = new IFoo;
auto* raw_foo2p = new IFoo;
raw_foo2p->AddRef();
nsCOMPtr<IFoo> foo1p( dont_AddRef(raw_foo1p) );

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

@ -246,7 +246,7 @@ nsresult
CreateIFoo( IFoo** result )
// a typical factory function (that calls AddRef)
{
IFoo* foop = new IFoo();
auto* foop = new IFoo();
foop->AddRef();
*result = foop;
@ -318,7 +318,7 @@ TEST(Hashtables, ClassHashtable)
nsClassHashtable<nsCStringHashKey,TestUniChar> EntToUniClass(ENTITY_COUNT);
for (auto& entity : gEntities) {
TestUniChar* temp = new TestUniChar(entity.mUnicode);
auto* temp = new TestUniChar(entity.mUnicode);
EntToUniClass.Put(nsDependentCString(entity.mStr), temp);
}

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

@ -128,7 +128,7 @@ nsresult
CreateFoo( void** result )
// a typical factory function (that calls AddRef)
{
Foo* foop = new Foo;
auto* foop = new Foo;
foop->AddRef();
*result = foop;
@ -331,10 +331,10 @@ TEST(nsRefPtr, AddRefHelpers)
Foo::total_addrefs_ = 0;
{
Foo* raw_foo1p = new Foo;
auto* raw_foo1p = new Foo;
raw_foo1p->AddRef();
Foo* raw_foo2p = new Foo;
auto* raw_foo2p = new Foo;
raw_foo2p->AddRef();
ASSERT_EQ(Foo::total_addrefs_, 2);