Bug 1217307 - Remove some unnecessary null checks in rest of dom/xul/. r=njn

This commit is contained in:
Birunthan Mohanathas 2015-11-19 09:13:49 +02:00
parent a2f3b6dcef
commit d127d5ac3d
13 changed files with 1 additions and 114 deletions

View File

@ -26,9 +26,6 @@ nsresult
RDFBindingSet::AddBinding(nsIAtom* aVar, nsIAtom* aRef, nsIRDFResource* aPredicate)
{
RDFBinding* newbinding = new RDFBinding(aRef, aPredicate, aVar);
if (! newbinding)
return NS_ERROR_OUT_OF_MEMORY;
if (mFirst) {
RDFBinding* binding = mFirst;
@ -208,9 +205,6 @@ nsBindingValues::SetBindingSet(RDFBindingSet* aBindings)
int32_t count = aBindings->Count();
if (count) {
mValues = new nsCOMPtr<nsIRDFNode>[count];
if (!mValues)
return NS_ERROR_OUT_OF_MEMORY;
mBindings = aBindings;
}
else {

View File

@ -209,10 +209,6 @@ nsRDFConInstanceTestNode::FilterInstantiations(InstantiationSet& aInstantiations
{
Element* element =
new nsRDFConInstanceTestNode::Element(valueres, container, empty);
if (! element)
return NS_ERROR_OUT_OF_MEMORY;
inst->AddSupportingElement(element);
}
else {

View File

@ -179,10 +179,6 @@ nsRDFConMemberTestNode::FilterInstantiations(InstantiationSet& aInstantiations,
Element* element =
new nsRDFConMemberTestNode::Element(containerRes,
memberValue);
if (! element)
return NS_ERROR_OUT_OF_MEMORY;
inst->AddSupportingElement(element);
}
else {
@ -231,10 +227,6 @@ nsRDFConMemberTestNode::FilterInstantiations(InstantiationSet& aInstantiations,
Element* element =
new nsRDFConMemberTestNode::Element(containerRes, node);
if (! element)
return NS_ERROR_OUT_OF_MEMORY;
newinst.AddSupportingElement(element);
aInstantiations.Insert(inst, newinst);
}
@ -320,10 +312,6 @@ nsRDFConMemberTestNode::FilterInstantiations(InstantiationSet& aInstantiations,
Element* element =
new nsRDFConMemberTestNode::Element(source,
memberValue);
if (! element)
return NS_ERROR_OUT_OF_MEMORY;
newinst.AddSupportingElement(element);
aInstantiations.Insert(inst, newinst);

View File

@ -180,10 +180,6 @@ nsRDFPropertyTestNode::FilterInstantiations(InstantiationSet& aInstantiations,
Element* element =
new nsRDFPropertyTestNode::Element(sourceRes, mProperty,
targetValue);
if (! element)
return NS_ERROR_OUT_OF_MEMORY;
inst->AddSupportingElement(element);
}
else {
@ -274,10 +270,6 @@ nsRDFPropertyTestNode::FilterInstantiations(InstantiationSet& aInstantiations,
Element* element =
new nsRDFPropertyTestNode::Element(sourceRes, mProperty,
targetValue);
if (! element)
return NS_ERROR_OUT_OF_MEMORY;
newinst.AddSupportingElement(element);
aInstantiations.Insert(inst, newinst);

View File

@ -33,9 +33,6 @@ nsRDFQuery::SetCachedResults(nsXULTemplateQueryProcessorRDF* aProcessor,
const InstantiationSet& aInstantiations)
{
mCachedResults = new nsXULTemplateResultSetRDF(aProcessor, this, &aInstantiations);
if (! mCachedResults)
return NS_ERROR_OUT_OF_MEMORY;
return NS_OK;
}

View File

@ -56,9 +56,6 @@ nsResourceSet::Add(nsIRDFResource* aResource)
if (mCount >= mCapacity) {
int32_t capacity = mCapacity + 4;
nsIRDFResource** resources = new nsIRDFResource*[capacity];
if (! resources)
return NS_ERROR_OUT_OF_MEMORY;
for (int32_t i = mCount - 1; i >= 0; --i)
resources[i] = mResources[i];

View File

@ -53,9 +53,6 @@ MemoryElementSet::Add(MemoryElement* aElement)
}
List* list = new List;
if (! list)
return NS_ERROR_OUT_OF_MEMORY;
list->mElement = aElement;
list->mRefCnt = 1;
list->mNext = mElements;
@ -78,9 +75,6 @@ nsAssignmentSet::Add(const nsAssignment& aAssignment)
return NS_ERROR_UNEXPECTED;
List* list = new List(aAssignment);
if (! list)
return NS_ERROR_OUT_OF_MEMORY;
list->mRefCnt = 1;
list->mNext = mAssignments;
@ -321,8 +315,6 @@ TestNode::Propagate(InstantiationSet& aInstantiations,
bool owned = false;
InstantiationSet* instantiations =
new InstantiationSet(aInstantiations);
if (!instantiations)
return NS_ERROR_OUT_OF_MEMORY;
rv = kid->Propagate(*instantiations, aIsUpdate, owned);
if (!owned)
delete instantiations;

View File

@ -348,9 +348,6 @@ NS_NewXULContentBuilder(nsISupports* aOuter, REFNSIID aIID, void** aResult)
nsresult rv;
nsXULContentBuilder* result = new nsXULContentBuilder();
if (!result)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(result); // stabilize
rv = result->InitGlobals();

View File

@ -502,9 +502,6 @@ nsresult
NS_NewXULSortService(nsIXULSortService** sortService)
{
*sortService = new XULSortServiceImpl();
if (!*sortService)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*sortService);
return NS_OK;
}

View File

@ -1210,15 +1210,12 @@ nsXULTemplateBuilder::LoadDataSources(nsIDocument* aDocument,
if (querytype.EqualsLiteral("rdf")) {
isRDFQuery = true;
mQueryProcessor = new nsXULTemplateQueryProcessorRDF();
NS_ENSURE_TRUE(mQueryProcessor, NS_ERROR_OUT_OF_MEMORY);
}
else if (querytype.EqualsLiteral("xml")) {
mQueryProcessor = new nsXULTemplateQueryProcessorXML();
NS_ENSURE_TRUE(mQueryProcessor, NS_ERROR_OUT_OF_MEMORY);
}
else if (querytype.EqualsLiteral("storage")) {
mQueryProcessor = new nsXULTemplateQueryProcessorStorage();
NS_ENSURE_TRUE(mQueryProcessor, NS_ERROR_OUT_OF_MEMORY);
}
else {
nsAutoCString cid(NS_QUERY_PROCESSOR_CONTRACTID_PREFIX);
@ -1749,9 +1746,6 @@ nsXULTemplateBuilder::CompileQueries()
mMemberVariable = do_GetAtom(membervar);
nsTemplateQuerySet* queryset = new nsTemplateQuerySet(0);
if (!queryset)
return NS_ERROR_OUT_OF_MEMORY;
if (!mQuerySets.AppendElement(queryset)) {
delete queryset;
return NS_ERROR_OUT_OF_MEMORY;
@ -1812,8 +1806,6 @@ nsXULTemplateBuilder::CompileTemplate(nsIContent* aTemplate,
// first one is always created by CompileQueries
if (hasQuerySet) {
aQuerySet = new nsTemplateQuerySet(++*aPriority);
if (!aQuerySet)
return NS_ERROR_OUT_OF_MEMORY;
// once the queryset is appended to the mQuerySets list, it
// will be removed by CompileQueries if an error occurs
@ -1892,9 +1884,6 @@ nsXULTemplateBuilder::CompileTemplate(nsIContent* aTemplate,
// create a new queryset if one hasn't been created already
if (hasQuerySet) {
aQuerySet = new nsTemplateQuerySet(++*aPriority);
if (! aQuerySet)
return NS_ERROR_OUT_OF_MEMORY;
if (!mQuerySets.AppendElement(aQuerySet)) {
delete aQuerySet;
return NS_ERROR_OUT_OF_MEMORY;
@ -1936,9 +1925,6 @@ nsXULTemplateBuilder::CompileTemplate(nsIContent* aTemplate,
// a new queryset must always be created in this case
if (hasQuerySet) {
aQuerySet = new nsTemplateQuerySet(++*aPriority);
if (! aQuerySet)
return NS_ERROR_OUT_OF_MEMORY;
if (!mQuerySets.AppendElement(aQuerySet)) {
delete aQuerySet;
return NS_ERROR_OUT_OF_MEMORY;
@ -2276,9 +2262,6 @@ nsXULTemplateBuilder::CompileWhereCondition(nsTemplateRule* aRule,
return NS_OK;
}
if (! condition)
return NS_ERROR_OUT_OF_MEMORY;
if (*aCurrentCondition) {
(*aCurrentCondition)->SetNext(condition);
}

View File

@ -407,8 +407,6 @@ nsXULTemplateQueryProcessorRDF::CompileQuery(nsIXULTemplateBuilder* aBuilder,
query->SetQueryNode(aQueryNode);
nsInstantiationNode* instnode = new nsInstantiationNode(this, query);
if (!instnode)
return NS_ERROR_OUT_OF_MEMORY;
// this and other functions always add nodes to mAllTests first. That
// way if something fails, the node will just sit harmlessly in mAllTests
@ -506,8 +504,6 @@ nsXULTemplateQueryProcessorRDF::GenerateResults(nsISupports* aDatasource,
seed.AddAssignment(query->mRefVariable, refResource);
InstantiationSet* instantiations = new InstantiationSet();
if (!instantiations)
return NS_ERROR_OUT_OF_MEMORY;
instantiations->Append(seed);
// if the propagation caused a match, then the results will be
@ -531,8 +527,6 @@ nsXULTemplateQueryProcessorRDF::GenerateResults(nsISupports* aDatasource,
if (! results) {
// no results were found so create an empty set
results = new nsXULTemplateResultSetRDF(this, query, nullptr);
if (! results)
return NS_ERROR_OUT_OF_MEMORY;
}
results.swap(*aResults);
@ -917,8 +911,6 @@ nsXULTemplateQueryProcessorRDF::Propagate(nsIRDFResource* aSource,
rdftestnode->CanPropagate(aSource, aProperty, aTarget, seed);
InstantiationSet* instantiations = new InstantiationSet();
if (!instantiations)
return NS_ERROR_OUT_OF_MEMORY;
instantiations->Append(seed);
rv = rdftestnode->Constrain(*instantiations);
@ -1190,11 +1182,8 @@ nsXULTemplateQueryProcessorRDF::CompileExtendedQuery(nsRDFQuery* aQuery,
TestNode** aLastNode)
{
// Compile an extended query's children
nsContentTestNode* idnode =
new nsContentTestNode(this, aQuery->mRefVariable);
if (! idnode)
return NS_ERROR_OUT_OF_MEMORY;
aQuery->SetRoot(idnode);
nsresult rv = mAllTests.Add(idnode);
@ -1397,11 +1386,9 @@ nsXULTemplateQueryProcessorRDF::CompileTripleCondition(nsRDFQuery* aQuery,
return NS_OK;
}
if (! testnode)
return NS_ERROR_OUT_OF_MEMORY;
// add testnode to mAllTests first. If adding to mRDFTests fails, just
// leave it in the list so that it can be deleted later.
MOZ_ASSERT(testnode);
nsresult rv = mAllTests.Add(testnode);
if (NS_FAILED(rv)) {
delete testnode;
@ -1455,9 +1442,6 @@ nsXULTemplateQueryProcessorRDF::CompileMemberCondition(nsRDFQuery* aQuery,
containervar,
childvar);
if (! testnode)
return NS_ERROR_OUT_OF_MEMORY;
// add testnode to mAllTests first. If adding to mRDFTests fails, just
// leave it in the list so that it can be deleted later.
nsresult rv = mAllTests.Add(testnode);
@ -1482,8 +1466,6 @@ nsXULTemplateQueryProcessorRDF::AddDefaultSimpleRules(nsRDFQuery* aQuery,
nsContentTestNode* idnode =
new nsContentTestNode(this,
aQuery->mRefVariable);
if (! idnode)
return NS_ERROR_OUT_OF_MEMORY;
// Create (?container ^member ?member)
nsRDFConMemberTestNode* membernode =
@ -1492,11 +1474,6 @@ nsXULTemplateQueryProcessorRDF::AddDefaultSimpleRules(nsRDFQuery* aQuery,
aQuery->mRefVariable,
aQuery->mMemberVariable);
if (! membernode) {
delete idnode;
return NS_ERROR_OUT_OF_MEMORY;
}
// add nodes to mAllTests first. If later calls fail, just leave them in
// the list so that they can be deleted later.
nsresult rv = mAllTests.Add(idnode);
@ -1605,9 +1582,6 @@ nsXULTemplateQueryProcessorRDF::CompileSimpleQuery(nsRDFQuery* aQuery,
iscontainer,
isempty);
if (! testnode)
return NS_ERROR_OUT_OF_MEMORY;
rv = mAllTests.Add(testnode);
if (NS_FAILED(rv)) {
delete testnode;
@ -1645,9 +1619,6 @@ nsXULTemplateQueryProcessorRDF::CompileSimpleQuery(nsRDFQuery* aQuery,
testnode = new nsRDFPropertyTestNode(prevnode, this,
aQuery->mMemberVariable, property, target);
if (! testnode)
return NS_ERROR_OUT_OF_MEMORY;
rv = mAllTests.Add(testnode);
if (NS_FAILED(rv)) {
delete testnode;
@ -1727,9 +1698,6 @@ nsXULTemplateQueryProcessorRDF::AddMemoryElements(const Instantiation& aInst,
nsCOMArray<nsXULTemplateResultRDF>* arr;
if (!mMemoryElementToResultMap.Get(hash, &arr)) {
arr = new nsCOMArray<nsXULTemplateResultRDF>();
if (!arr)
return NS_ERROR_OUT_OF_MEMORY;
mMemoryElementToResultMap.Put(hash, arr);
}

View File

@ -79,10 +79,6 @@ nsXULTemplateResultSetStorage::GetNext(nsISupports **aResult)
{
nsXULTemplateResultStorage* result =
new nsXULTemplateResultStorage(this);
if (!result)
return NS_ERROR_OUT_OF_MEMORY;
*aResult = result;
NS_ADDREF(result);
return NS_OK;
@ -405,10 +401,6 @@ nsXULTemplateQueryProcessorStorage::GenerateResults(nsISupports* aDatasource,
nsXULTemplateResultSetStorage* results =
new nsXULTemplateResultSetStorage(statement);
if (!results)
return NS_ERROR_OUT_OF_MEMORY;
*aResults = results;
NS_ADDREF(*aResults);
@ -431,9 +423,6 @@ nsXULTemplateQueryProcessorStorage::TranslateRef(nsISupports* aDatasource,
{
nsXULTemplateResultStorage* result =
new nsXULTemplateResultStorage(nullptr);
if (!result)
return NS_ERROR_OUT_OF_MEMORY;
*aRef = result;
NS_ADDREF(*aRef);
return NS_OK;

View File

@ -262,9 +262,6 @@ NS_NewXULTreeBuilder(nsISupports* aOuter, REFNSIID aIID, void** aResult)
nsresult rv;
nsXULTreeBuilder* result = new nsXULTreeBuilder();
if (! result)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(result); // stabilize
rv = result->InitGlobals();