summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-09-17 23:36:22 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-09-17 23:36:22 +0000
commite063301440f00207c5d72a01883777adb1686455 (patch)
treebb1df3b68cfc44e1aa419bfa3671f9cb46ad18ee
parent4c3b4aa6d1df54fe02912fed04a08adc6826310f (diff)
downloadpdfium-e063301440f00207c5d72a01883777adb1686455.tar.xz
Replace CJS_GlobalVariableArray::Copy() with operator=().
Change-Id: I71794f87a99f9dcbb04296f42e8a5cd55656bd90 Reviewed-on: https://pdfium-review.googlesource.com/42615 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
-rw-r--r--fxjs/cjs_globaldata.cpp4
-rw-r--r--fxjs/cjs_globalvariablearray.cpp13
-rw-r--r--fxjs/cjs_globalvariablearray.h3
3 files changed, 13 insertions, 7 deletions
diff --git a/fxjs/cjs_globaldata.cpp b/fxjs/cjs_globaldata.cpp
index de240cf453..614ae15858 100644
--- a/fxjs/cjs_globaldata.cpp
+++ b/fxjs/cjs_globaldata.cpp
@@ -149,13 +149,13 @@ void CJS_GlobalData::SetGlobalVariableObject(
if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName)) {
pData->data.nType = JS_GlobalDataType::OBJECT;
- pData->data.objData.Copy(array);
+ pData->data.objData = array;
return;
}
auto pNewData = pdfium::MakeUnique<CJS_GlobalData_Element>();
pNewData->data.sKey = std::move(sPropName);
pNewData->data.nType = JS_GlobalDataType::OBJECT;
- pNewData->data.objData.Copy(array);
+ pNewData->data.objData = array;
m_arrayGlobalData.push_back(std::move(pNewData));
}
diff --git a/fxjs/cjs_globalvariablearray.cpp b/fxjs/cjs_globalvariablearray.cpp
index c4ac00cc9a..e8155b6dc0 100644
--- a/fxjs/cjs_globalvariablearray.cpp
+++ b/fxjs/cjs_globalvariablearray.cpp
@@ -15,10 +15,14 @@ CJS_GlobalVariableArray::CJS_GlobalVariableArray() {}
CJS_GlobalVariableArray::~CJS_GlobalVariableArray() {}
-void CJS_GlobalVariableArray::Copy(const CJS_GlobalVariableArray& array) {
+CJS_GlobalVariableArray& CJS_GlobalVariableArray::operator=(
+ const CJS_GlobalVariableArray& that) {
+ if (this == &that)
+ return *this;
+
m_Array.clear();
- for (int i = 0, sz = array.Count(); i < sz; i++) {
- CJS_KeyValue* pOldObjData = array.GetAt(i);
+ for (int i = 0, sz = that.Count(); i < sz; i++) {
+ CJS_KeyValue* pOldObjData = that.GetAt(i);
switch (pOldObjData->nType) {
case JS_GlobalDataType::NUMBER: {
auto pNewObjData = pdfium::MakeUnique<CJS_KeyValue>();
@@ -45,7 +49,7 @@ void CJS_GlobalVariableArray::Copy(const CJS_GlobalVariableArray& array) {
auto pNewObjData = pdfium::MakeUnique<CJS_KeyValue>();
pNewObjData->sKey = pOldObjData->sKey;
pNewObjData->nType = pOldObjData->nType;
- pNewObjData->objData.Copy(pOldObjData->objData);
+ pNewObjData->objData = pOldObjData->objData;
Add(std::move(pNewObjData));
} break;
case JS_GlobalDataType::NULLOBJ: {
@@ -56,6 +60,7 @@ void CJS_GlobalVariableArray::Copy(const CJS_GlobalVariableArray& array) {
} break;
}
}
+ return *this;
}
void CJS_GlobalVariableArray::Add(std::unique_ptr<CJS_KeyValue> pKeyValue) {
diff --git a/fxjs/cjs_globalvariablearray.h b/fxjs/cjs_globalvariablearray.h
index a3f46586b9..ae98d3e044 100644
--- a/fxjs/cjs_globalvariablearray.h
+++ b/fxjs/cjs_globalvariablearray.h
@@ -17,10 +17,11 @@ class CJS_GlobalVariableArray {
CJS_GlobalVariableArray();
~CJS_GlobalVariableArray();
+ CJS_GlobalVariableArray& operator=(const CJS_GlobalVariableArray& array);
+
void Add(std::unique_ptr<CJS_KeyValue> pKeyValue);
int Count() const;
CJS_KeyValue* GetAt(int index) const;
- void Copy(const CJS_GlobalVariableArray& array);
private:
std::vector<std::unique_ptr<CJS_KeyValue>> m_Array;