Kaydet (Commit) 4931d3e5 authored tarafından Kohei Yoshida's avatar Kohei Yoshida

Actually we can just swap them. The originals are not used after this call.

This avoids redundant copying of vectors.

Change-Id: I1da8295774a1a39fd4df021fee1a3036134067a8
üst c669d9e6
......@@ -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 );
......
......@@ -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 )
......
......@@ -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 );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment