commit f0ea03d24401de4aada28c6f50e5669e949255dd
parent e3b38e22e39cfe011c8e0a56ea49b72f1c76f097
Author: Emilio Cobos Álvarez <emilio@crisal.io>
Date: Wed, 31 Dec 2025 17:19:52 +0000
Bug 2007958 - Drive-by simplifications in nsXULPrototypeDocument. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D277644
Diffstat:
1 file changed, 7 insertions(+), 16 deletions(-)
diff --git a/dom/xul/nsXULPrototypeDocument.cpp b/dom/xul/nsXULPrototypeDocument.cpp
@@ -204,17 +204,16 @@ nsXULPrototypeDocument::Read(nsIObjectInputStream* aStream) {
return NotifyLoadDone();
}
-static nsresult GetNodeInfos(nsXULPrototypeElement* aPrototype,
- nsTArray<RefPtr<mozilla::dom::NodeInfo>>& aArray) {
+static void GetNodeInfos(nsXULPrototypeElement* aPrototype,
+ nsTArray<RefPtr<mozilla::dom::NodeInfo>>& aArray) {
if (aArray.IndexOf(aPrototype->mNodeInfo) == aArray.NoIndex) {
aArray.AppendElement(aPrototype->mNodeInfo);
}
// Search attributes
- size_t i;
- for (i = 0; i < aPrototype->mAttributes.Length(); ++i) {
+ for (nsXULPrototypeAttribute& attr : aPrototype->mAttributes) {
RefPtr<mozilla::dom::NodeInfo> ni;
- nsAttrName* name = &aPrototype->mAttributes[i].mName;
+ nsAttrName* name = &attr.mName;
if (name->IsAtom()) {
ni = aPrototype->mNodeInfo->NodeInfoManager()->GetNodeInfo(
name->Atom(), nullptr, kNameSpaceID_None, nsINode::ATTRIBUTE_NODE);
@@ -228,16 +227,11 @@ static nsresult GetNodeInfos(nsXULPrototypeElement* aPrototype,
}
// Search children
- for (i = 0; i < aPrototype->mChildren.Length(); ++i) {
- nsXULPrototypeNode* child = aPrototype->mChildren[i];
+ for (nsXULPrototypeNode* child : aPrototype->mChildren) {
if (child->mType == nsXULPrototypeNode::eType_Element) {
- nsresult rv =
- GetNodeInfos(static_cast<nsXULPrototypeElement*>(child), aArray);
- NS_ENSURE_SUCCESS(rv, rv);
+ GetNodeInfos(static_cast<nsXULPrototypeElement*>(child), aArray);
}
}
-
- return NS_OK;
}
NS_IMETHODIMP
@@ -270,10 +264,7 @@ nsXULPrototypeDocument::Write(nsIObjectOutputStream* aStream) {
// mozilla::dom::NodeInfo table
nsTArray<RefPtr<mozilla::dom::NodeInfo>> nodeInfos;
if (mRoot) {
- tmp = GetNodeInfos(mRoot, nodeInfos);
- if (NS_FAILED(tmp)) {
- rv = tmp;
- }
+ GetNodeInfos(mRoot, nodeInfos);
}
uint32_t nodeInfoCount = nodeInfos.Length();