summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@suse.com>2012-02-28 14:07:38 -0500
committerKohei Yoshida <kohei.yoshida@suse.com>2012-02-28 21:03:06 -0500
commit94b7deccb683fc407a90c3bb1f580ca47debaf33 (patch)
treedc02eed1fbc4c0be937271ba0ed1d4845d870199
parent2c0c947a99f0c9e96e64a5d95ea31329eb0b1eee (diff)
We only use the string part. Let's make it more obvious.
Plus this will save some memory footprint.
-rw-r--r--sc/inc/dptablecache.hxx3
-rw-r--r--sc/source/core/data/dptablecache.cxx14
2 files changed, 9 insertions, 8 deletions
diff --git a/sc/inc/dptablecache.hxx b/sc/inc/dptablecache.hxx
index 838499b4e295..95d4d89b39a9 100644
--- a/sc/inc/dptablecache.hxx
+++ b/sc/inc/dptablecache.hxx
@@ -57,6 +57,7 @@ class SC_DLLPUBLIC ScDPCache : boost::noncopyable
public:
typedef ::boost::ptr_vector<ScDPItemData> DataListType;
typedef std::set<ScDPObject*> ObjectSetType;
+ typedef std::vector<rtl::OUString> LabelsType;
private:
typedef ::boost::ptr_vector<DataListType> DataGridType;
typedef ::boost::ptr_vector< ::std::vector<SCROW> > RowGridType;
@@ -94,7 +95,7 @@ private:
*/
mutable RowGridType maIndexOrder;
- DataListType maLabelNames; // Stores dimension names.
+ LabelsType maLabelNames; // Stores dimension names.
std::vector<bool> mbEmptyRow; // Keeps track of empty rows.
boost::scoped_ptr<ScDPItemDataPool> mpAdditionalData;
diff --git a/sc/source/core/data/dptablecache.cxx b/sc/source/core/data/dptablecache.cxx
index b54322e30e0f..35936d901ec3 100644
--- a/sc/source/core/data/dptablecache.cxx
+++ b/sc/source/core/data/dptablecache.cxx
@@ -630,7 +630,7 @@ rtl::OUString ScDPCache::GetDimensionName( sal_uInt16 nColumn ) const
if ( static_cast<size_t>(nColumn+1) < maLabelNames.size() )
{
- return maLabelNames[nColumn+1].maString;
+ return maLabelNames[nColumn+1];
}
else
return rtl::OUString();
@@ -655,28 +655,28 @@ public:
void ScDPCache::AddLabel(ScDPItemData *pData)
{
+ std::auto_ptr<ScDPItemData> p(pData);
OSL_ENSURE( IsValid(), " IsValid() == false " );
if ( maLabelNames.empty() )
- maLabelNames.push_back( new ScDPItemData(ScGlobal::GetRscString(STR_PIVOT_DATA)) );
+ maLabelNames.push_back(ScGlobal::GetRscString(STR_PIVOT_DATA));
//reset name if needed
LabelSet aExistingNames;
std::for_each(maLabelNames.begin(), maLabelNames.end(), InsertLabel(aExistingNames));
sal_Int32 nSuffix = 1;
- rtl::OUString aNewName = pData->GetString();
+ rtl::OUString aNewName = p->GetString();
while (true)
{
if (!aExistingNames.count(aNewName))
{
// unique name found!
- pData->maString = aNewName;
- maLabelNames.push_back(pData);
+ maLabelNames.push_back(aNewName);
return;
}
// Name already exists.
- rtl::OUStringBuffer aBuf(pData->GetString());
+ rtl::OUStringBuffer aBuf(p->GetString());
aBuf.append(++nSuffix);
aNewName = aBuf.makeStringAndClear();
}
@@ -777,7 +777,7 @@ SCCOL ScDPCache::GetDimensionIndex(const rtl::OUString& sName) const
{
for (size_t i = 1; i < maLabelNames.size(); ++i)
{
- if (maLabelNames[i].GetString().equals(sName))
+ if (maLabelNames[i].equals(sName))
return (SCCOL)(i-1);
}
return -1;