summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2013-02-14 20:44:23 -0500
committerKohei Yoshida <kohei.yoshida@gmail.com>2013-02-14 20:58:33 -0500
commit4931d3e5cfc83827faa26377ee77b9839ab93b9c (patch)
tree079059683d6bc035c71b2342adb007cd5724bd22
parentc669d9e645b7600cf8ed0cc696e99f4552b167a4 (diff)
Actually we can just swap them. The originals are not used after this call.
This avoids redundant copying of vectors. Change-Id: I1da8295774a1a39fd4df021fee1a3036134067a8
-rw-r--r--sc/inc/dptabres.hxx10
-rw-r--r--sc/source/core/data/dptabres.cxx35
-rw-r--r--sc/source/core/data/dptabsrc.cxx11
3 files changed, 15 insertions, 41 deletions
diff --git a/sc/inc/dptabres.hxx b/sc/inc/dptabres.hxx
index 989e8d377446..bd628d048b27 100644
--- a/sc/inc/dptabres.hxx
+++ b/sc/inc/dptabres.hxx
@@ -292,7 +292,7 @@ class ScDPResultData
std::vector<ScSubTotalFunc> maMeasureFuncs;
std::vector<com::sun::star::sheet::DataPilotFieldReference> maMeasureRefs;
std::vector<sal_uInt16> maMeasureRefOrients;
- std::vector<rtl::OUString> maMeasureNames;
+ std::vector<OUString> maMeasureNames;
bool bLateInit:1;
bool bDataAtCol:1;
@@ -304,9 +304,11 @@ public:
ScDPResultData( ScDPSource& rSrc );
~ScDPResultData();
- void SetMeasureData( long nCount, const ScSubTotalFunc* pFunctions,
- const ::com::sun::star::sheet::DataPilotFieldReference* pRefs,
- const sal_uInt16* pRefOrient, std::vector<rtl::OUString>& rNames );
+ void SetMeasureData(
+ std::vector<ScSubTotalFunc>& rFunctions,
+ std::vector<com::sun::star::sheet::DataPilotFieldReference>& rRefs,
+ std::vector<sal_uInt16>& rRefOrient, std::vector<OUString>& rNames );
+
void SetDataLayoutOrientation( sal_uInt16 nOrient );
void SetLateInit( bool bSet );
diff --git a/sc/source/core/data/dptabres.cxx b/sc/source/core/data/dptabres.cxx
index 3499300f325f..8fa53a42840c 100644
--- a/sc/source/core/data/dptabres.cxx
+++ b/sc/source/core/data/dptabres.cxx
@@ -724,33 +724,14 @@ ScDPResultData::~ScDPResultData()
std::for_each(maDimMembers.begin(), maDimMembers.end(), ScDeleteObjectByPtr<ResultMembers>());
}
-void ScDPResultData::SetMeasureData( long nCount, const ScSubTotalFunc* pFunctions,
- const sheet::DataPilotFieldReference* pRefs, const sal_uInt16* pRefOrient,
- std::vector<rtl::OUString>& rNames )
-{
- maMeasureFuncs.clear();
- maMeasureRefs.clear();
- maMeasureRefOrients.clear();
-
- if ( nCount )
- {
- OSL_ASSERT(nCount == static_cast<long>(rNames.size()));
- maMeasureFuncs.assign(pFunctions, pFunctions+nCount);
- maMeasureRefs.assign(pRefs, pRefs+nCount);
- maMeasureRefOrients.assign(pRefOrient, pRefOrient+nCount);
- maMeasureNames.swap(rNames);
- }
- else
- {
- // use one dummy measure
- maMeasureFuncs.push_back(SUBTOTAL_FUNC_NONE);
- maMeasureRefs.push_back(sheet::DataPilotFieldReference()); // default ctor is ok
- maMeasureRefOrients.push_back(sheet::DataPilotFieldOrientation_HIDDEN);
-
- std::vector<rtl::OUString> aMeasureName;
- aMeasureName.push_back(ScGlobal::GetRscString(STR_EMPTYDATA));
- maMeasureNames.swap(aMeasureName);
- }
+void ScDPResultData::SetMeasureData(
+ std::vector<ScSubTotalFunc>& rFunctions, std::vector<sheet::DataPilotFieldReference>& rRefs,
+ std::vector<sal_uInt16>& rRefOrient, std::vector<OUString>& rNames )
+{
+ maMeasureFuncs.swap(rFunctions);
+ maMeasureRefs.swap(rRefs);
+ maMeasureRefOrients.swap(rRefOrient);
+ maMeasureNames.swap(rNames);
}
void ScDPResultData::SetDataLayoutOrientation( sal_uInt16 nOrient )
diff --git a/sc/source/core/data/dptabsrc.cxx b/sc/source/core/data/dptabsrc.cxx
index 2d7b6e3d4790..7fdf75cf5550 100644
--- a/sc/source/core/data/dptabsrc.cxx
+++ b/sc/source/core/data/dptabsrc.cxx
@@ -841,16 +841,7 @@ void ScDPSource::CreateRes_Impl()
}
pResData = new ScDPResultData(*this);
- const ScSubTotalFunc* pDataFunctions = NULL;
- const sheet::DataPilotFieldReference* pDataRefValues = NULL;
- const sal_uInt16* pDataRefOrient = NULL;
- if (!maDataDims.empty())
- {
- pDataFunctions = &aDataFunctions[0];
- pDataRefValues = &aDataRefValues[0];
- pDataRefOrient = &aDataRefOrient[0];
- }
- pResData->SetMeasureData(maDataDims.size(), pDataFunctions, pDataRefValues, pDataRefOrient, aDataNames);
+ pResData->SetMeasureData(aDataFunctions, aDataRefValues, aDataRefOrient, aDataNames);
pResData->SetDataLayoutOrientation(nDataOrient);
pResData->SetLateInit( bLateInit );