summaryrefslogtreecommitdiff
path: root/fxjs/cjs_globaldata.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-10-17 21:53:43 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-10-17 21:53:43 +0000
commita8a69e742f57a58a61555242751542fbc3fc5267 (patch)
treecc83f7fdb87aa2f4aee3ca15c119a589d032e359 /fxjs/cjs_globaldata.cpp
parentd78358d506c2e700a1177f93bdb915154eefae5c (diff)
downloadpdfium-a8a69e742f57a58a61555242751542fbc3fc5267.tar.xz
Nest CJS_GlobalData_Element in CJS_GlobalData.
Why settle for _ when you can have :: ? No functional change. Move some ctors/initializers out of line and avoid assignment in some ifs. Change-Id: I792bca35f38aa8c4ff41d776a789c5525c5d5113 Reviewed-on: https://pdfium-review.googlesource.com/c/44212 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fxjs/cjs_globaldata.cpp')
-rw-r--r--fxjs/cjs_globaldata.cpp38
1 files changed, 23 insertions, 15 deletions
diff --git a/fxjs/cjs_globaldata.cpp b/fxjs/cjs_globaldata.cpp
index 0c84d1db72..0872b6af7b 100644
--- a/fxjs/cjs_globaldata.cpp
+++ b/fxjs/cjs_globaldata.cpp
@@ -55,8 +55,7 @@ void CJS_GlobalData::Release() {
}
}
-CJS_GlobalData::CJS_GlobalData()
- : m_RefCount(0), m_sFilePath(SDK_JS_GLOBALDATA_FILENAME) {
+CJS_GlobalData::CJS_GlobalData() : m_sFilePath(SDK_JS_GLOBALDATA_FILENAME) {
LoadGlobalPersistentVariables();
}
@@ -84,7 +83,7 @@ CJS_GlobalData::const_iterator CJS_GlobalData::FindGlobalVariable(
return m_arrayGlobalData.end();
}
-CJS_GlobalData_Element* CJS_GlobalData::GetGlobalVariable(
+CJS_GlobalData::Element* CJS_GlobalData::GetGlobalVariable(
const ByteString& propname) {
auto iter = FindGlobalVariable(propname);
return iter != m_arrayGlobalData.end() ? iter->get() : nullptr;
@@ -95,12 +94,13 @@ void CJS_GlobalData::SetGlobalVariableNumber(ByteString sPropName,
if (!TrimPropName(&sPropName))
return;
- if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName)) {
+ CJS_GlobalData::Element* pData = GetGlobalVariable(sPropName);
+ if (pData) {
pData->data.nType = JS_GlobalDataType::NUMBER;
pData->data.dData = dData;
return;
}
- auto pNewData = pdfium::MakeUnique<CJS_GlobalData_Element>();
+ auto pNewData = pdfium::MakeUnique<CJS_GlobalData::Element>();
pNewData->data.sKey = std::move(sPropName);
pNewData->data.nType = JS_GlobalDataType::NUMBER;
pNewData->data.dData = dData;
@@ -112,12 +112,13 @@ void CJS_GlobalData::SetGlobalVariableBoolean(ByteString sPropName,
if (!TrimPropName(&sPropName))
return;
- if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName)) {
+ CJS_GlobalData::Element* pData = GetGlobalVariable(sPropName);
+ if (pData) {
pData->data.nType = JS_GlobalDataType::BOOLEAN;
pData->data.bData = bData;
return;
}
- auto pNewData = pdfium::MakeUnique<CJS_GlobalData_Element>();
+ auto pNewData = pdfium::MakeUnique<CJS_GlobalData::Element>();
pNewData->data.sKey = std::move(sPropName);
pNewData->data.nType = JS_GlobalDataType::BOOLEAN;
pNewData->data.bData = bData;
@@ -129,12 +130,13 @@ void CJS_GlobalData::SetGlobalVariableString(ByteString sPropName,
if (!TrimPropName(&sPropName))
return;
- if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName)) {
+ CJS_GlobalData::Element* pData = GetGlobalVariable(sPropName);
+ if (pData) {
pData->data.nType = JS_GlobalDataType::STRING;
pData->data.sData = sData;
return;
}
- auto pNewData = pdfium::MakeUnique<CJS_GlobalData_Element>();
+ auto pNewData = pdfium::MakeUnique<CJS_GlobalData::Element>();
pNewData->data.sKey = std::move(sPropName);
pNewData->data.nType = JS_GlobalDataType::STRING;
pNewData->data.sData = sData;
@@ -147,12 +149,13 @@ void CJS_GlobalData::SetGlobalVariableObject(
if (!TrimPropName(&sPropName))
return;
- if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName)) {
+ CJS_GlobalData::Element* pData = GetGlobalVariable(sPropName);
+ if (pData) {
pData->data.nType = JS_GlobalDataType::OBJECT;
pData->data.objData = array;
return;
}
- auto pNewData = pdfium::MakeUnique<CJS_GlobalData_Element>();
+ auto pNewData = pdfium::MakeUnique<CJS_GlobalData::Element>();
pNewData->data.sKey = std::move(sPropName);
pNewData->data.nType = JS_GlobalDataType::OBJECT;
pNewData->data.objData = array;
@@ -163,11 +166,12 @@ void CJS_GlobalData::SetGlobalVariableNull(ByteString sPropName) {
if (!TrimPropName(&sPropName))
return;
- if (CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName)) {
+ CJS_GlobalData::Element* pData = GetGlobalVariable(sPropName);
+ if (pData) {
pData->data.nType = JS_GlobalDataType::NULLOBJ;
return;
}
- auto pNewData = pdfium::MakeUnique<CJS_GlobalData_Element>();
+ auto pNewData = pdfium::MakeUnique<CJS_GlobalData::Element>();
pNewData->data.sKey = std::move(sPropName);
pNewData->data.nType = JS_GlobalDataType::NULLOBJ;
m_arrayGlobalData.push_back(std::move(pNewData));
@@ -178,7 +182,7 @@ bool CJS_GlobalData::SetGlobalVariablePersistent(ByteString sPropName,
if (!TrimPropName(&sPropName))
return false;
- CJS_GlobalData_Element* pData = GetGlobalVariable(sPropName);
+ CJS_GlobalData::Element* pData = GetGlobalVariable(sPropName);
if (!pData)
return false;
@@ -202,7 +206,7 @@ int32_t CJS_GlobalData::GetSize() const {
return pdfium::CollectionSize<int32_t>(m_arrayGlobalData);
}
-CJS_GlobalData_Element* CJS_GlobalData::GetAt(int index) const {
+CJS_GlobalData::Element* CJS_GlobalData::GetAt(int index) const {
if (index < 0 || index >= GetSize())
return nullptr;
return m_arrayGlobalData[index].get();
@@ -384,3 +388,7 @@ void CJS_GlobalData::MakeByteString(const ByteString& name,
break;
}
}
+
+CJS_GlobalData::Element::Element() = default;
+
+CJS_GlobalData::Element::~Element() = default;