Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Unified Diff: fpdfsdk/include/fsdk_mgr.h

Issue 1652613002: Remove CGW_ArrayTemplate and its O(n^2 log n) sort. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Another pointless empty() check. Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « fpdfsdk/include/fsdk_baseform.h ('k') | fpdfsdk/src/fsdk_baseform.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fpdfsdk/include/fsdk_mgr.h
diff --git a/fpdfsdk/include/fsdk_mgr.h b/fpdfsdk/include/fsdk_mgr.h
index 4b07cc31274cebd099f43bdb09becec7bf3f6c14..323b07a46dcedfa3400b692c8a076885ae1fdc7d 100644
--- a/fpdfsdk/include/fsdk_mgr.h
+++ b/fpdfsdk/include/fsdk_mgr.h
@@ -292,6 +292,7 @@ class CPDFSDK_Document {
FX_BOOL m_bChangeMask;
FX_BOOL m_bBeingDestroyed;
};
+
class CPDFSDK_PageView final {
public:
CPDFSDK_PageView(CPDFSDK_Document* pSDKDoc, UnderlyingPageType* page);
@@ -368,77 +369,4 @@ class CPDFSDK_PageView final {
FX_BOOL m_bTakeOverPage;
};
-template <class TYPE>
-class CGW_ArrayTemplate : public CFX_ArrayTemplate<TYPE> {
- public:
- CGW_ArrayTemplate() {}
- ~CGW_ArrayTemplate() {}
-
- typedef int (*LP_COMPARE)(TYPE p1, TYPE p2);
-
- void Sort(LP_COMPARE pCompare, FX_BOOL bAscent = TRUE) {
- int nSize = this->GetSize();
- QuickSort(0, nSize - 1, bAscent, pCompare);
- }
-
- private:
- void QuickSort(FX_UINT nStartPos,
- FX_UINT nStopPos,
- FX_BOOL bAscend,
- LP_COMPARE pCompare) {
- if (nStartPos >= nStopPos)
- return;
-
- if ((nStopPos - nStartPos) == 1) {
- TYPE Value1 = this->GetAt(nStartPos);
- TYPE Value2 = this->GetAt(nStopPos);
-
- int iGreate = (*pCompare)(Value1, Value2);
- if ((bAscend && iGreate > 0) || (!bAscend && iGreate < 0)) {
- this->SetAt(nStartPos, Value2);
- this->SetAt(nStopPos, Value1);
- }
- return;
- }
-
- FX_UINT m = nStartPos + (nStopPos - nStartPos) / 2;
- FX_UINT i = nStartPos;
-
- TYPE Value = this->GetAt(m);
-
- while (i < m) {
- TYPE temp = this->GetAt(i);
-
- int iGreate = (*pCompare)(temp, Value);
- if ((bAscend && iGreate > 0) || (!bAscend && iGreate < 0)) {
- this->InsertAt(m + 1, temp);
- this->RemoveAt(i);
- m--;
- } else {
- i++;
- }
- }
-
- FX_UINT j = nStopPos;
-
- while (j > m) {
- TYPE temp = this->GetAt(j);
-
- int iGreate = (*pCompare)(temp, Value);
- if ((bAscend && iGreate < 0) || (!bAscend && iGreate > 0)) {
- this->RemoveAt(j);
- this->InsertAt(m, temp);
- m++;
- } else {
- j--;
- }
- }
-
- if (nStartPos < m)
- QuickSort(nStartPos, m, bAscend, pCompare);
- if (nStopPos > m)
- QuickSort(m, nStopPos, bAscend, pCompare);
- }
-};
-
#endif // FPDFSDK_INCLUDE_FSDK_MGR_H_
« no previous file with comments | « fpdfsdk/include/fsdk_baseform.h ('k') | fpdfsdk/src/fsdk_baseform.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698