From 6520c8f2f3271c2f36429084a6b0f737f2ad4b88 Mon Sep 17 00:00:00 2001 From: Tamás Zolnai Date: Fri, 14 Oct 2016 21:02:32 +0000 Subject: PivotTable cache: Remove useless mnValueSortIndex We can use mnOrderIndex to get the same result. Change-Id: I71f68ebefe08c3664954ecdf6345cca4ed5ccafc --- sc/source/core/data/dpcache.cxx | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) (limited to 'sc') diff --git a/sc/source/core/data/dpcache.cxx b/sc/source/core/data/dpcache.cxx index 25a500c96ff3..49b1d61452ac 100644 --- a/sc/source/core/data/dpcache.cxx +++ b/sc/source/core/data/dpcache.cxx @@ -153,9 +153,8 @@ struct Bucket ScDPItemData maValue; SCROW mnOrderIndex; SCROW mnDataIndex; - SCROW mnValueSortIndex; Bucket(const ScDPItemData& rValue, SCROW nData) : - maValue(rValue), mnOrderIndex(0), mnDataIndex(nData), mnValueSortIndex(0) {} + maValue(rValue), mnOrderIndex(0), mnDataIndex(nData) {} }; #if DEBUG_PIVOT_TABLE @@ -167,7 +166,7 @@ struct PrintBucket : std::unary_function { void operator() (const Bucket& v) const { - cout << "value: " << v.maValue.GetValue() << " order index: " << v.mnOrderIndex << " data index: " << v.mnDataIndex << " value sort index: " << v.mnValueSortIndex << endl; + cout << "value: " << v.maValue.GetValue() << " order index: " << v.mnOrderIndex << " data index: " << v.mnDataIndex << endl; } }; @@ -181,11 +180,11 @@ struct LessByValue : std::binary_function } }; -struct LessByValueSortIndex : std::binary_function +struct LessByOrderIndex : std::binary_function { bool operator() (const Bucket& left, const Bucket& right) const { - return left.mnValueSortIndex < right.mnValueSortIndex; + return left.mnOrderIndex < right.mnOrderIndex; } }; @@ -227,17 +226,6 @@ public: } }; -class TagValueSortOrder : public std::unary_function -{ - SCROW mnCurIndex; -public: - TagValueSortOrder() : mnCurIndex(0) {} - void operator() (Bucket& v) - { - v.mnValueSortIndex = mnCurIndex++; - } -}; - void processBuckets(std::vector& aBuckets, ScDPCache::Field& rField) { if (aBuckets.empty()) @@ -246,9 +234,6 @@ void processBuckets(std::vector& aBuckets, ScDPCache::Field& rField) // Sort by the value. std::sort(aBuckets.begin(), aBuckets.end(), LessByValue()); - // Remember this sort order. - std::for_each(aBuckets.begin(), aBuckets.end(), TagValueSortOrder()); - { // Set order index such that unique values have identical index value. SCROW nCurIndex = 0; @@ -273,7 +258,7 @@ void processBuckets(std::vector& aBuckets, ScDPCache::Field& rField) std::for_each(aBuckets.begin(), aBuckets.end(), PushBackOrderIndex(rField.maData)); // Sort by the value again. - std::sort(aBuckets.begin(), aBuckets.end(), LessByValueSortIndex()); + std::sort(aBuckets.begin(), aBuckets.end(), LessByOrderIndex()); // Unique by value. std::vector::iterator itUniqueEnd = -- cgit