Small cleanup in CXFA_ArrayNodeList::SetArrayNodeList()
Remove no-op call with empty vector.
Avoid copy-assign when caller already has an rvalue.
Change-Id: I446324d877b254905997df543b6ffd2c44a42eb1
Reviewed-on: https://pdfium-review.googlesource.com/c/47870
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/fxjs/xfa/cjx_form.cpp b/fxjs/xfa/cjx_form.cpp
index a4d23e7..3004866 100644
--- a/fxjs/xfa/cjx_form.cpp
+++ b/fxjs/xfa/cjx_form.cpp
@@ -42,10 +42,7 @@
if (!pDataNode)
return CJS_Result::Failure(JSMessage::kValueError);
- std::vector<CXFA_Node*> formItems;
CXFA_ArrayNodeList* pFormNodes = new CXFA_ArrayNodeList(GetDocument());
- pFormNodes->SetArrayNodeList(formItems);
-
CFXJSE_Value* value =
GetDocument()->GetScriptContext()->GetJSValueFromMap(pFormNodes);
if (!value)
diff --git a/xfa/fxfa/parser/cxfa_arraynodelist.cpp b/xfa/fxfa/parser/cxfa_arraynodelist.cpp
index 3c3ba29..704ad54 100644
--- a/xfa/fxfa/parser/cxfa_arraynodelist.cpp
+++ b/xfa/fxfa/parser/cxfa_arraynodelist.cpp
@@ -6,6 +6,7 @@
#include "xfa/fxfa/parser/cxfa_arraynodelist.h"
+#include <utility>
#include <vector>
CXFA_ArrayNodeList::CXFA_ArrayNodeList(CXFA_Document* pDocument)
@@ -13,10 +14,9 @@
CXFA_ArrayNodeList::~CXFA_ArrayNodeList() {}
-void CXFA_ArrayNodeList::SetArrayNodeList(
- const std::vector<CXFA_Node*>& srcArray) {
+void CXFA_ArrayNodeList::SetArrayNodeList(std::vector<CXFA_Node*> srcArray) {
if (!srcArray.empty())
- m_array = srcArray;
+ m_array = std::move(srcArray);
}
size_t CXFA_ArrayNodeList::GetLength() {
diff --git a/xfa/fxfa/parser/cxfa_arraynodelist.h b/xfa/fxfa/parser/cxfa_arraynodelist.h
index d723df3..b00b4a8 100644
--- a/xfa/fxfa/parser/cxfa_arraynodelist.h
+++ b/xfa/fxfa/parser/cxfa_arraynodelist.h
@@ -26,7 +26,7 @@
void Remove(CXFA_Node* pNode) override;
CXFA_Node* Item(size_t iIndex) override;
- void SetArrayNodeList(const std::vector<CXFA_Node*>& srcArray);
+ void SetArrayNodeList(std::vector<CXFA_Node*> srcArray);
private:
std::vector<CXFA_Node*> m_array;