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

Unified Diff: src/gpu/gl/GrGLExtensions.cpp

Issue 12316141: Sort GL extension strings and search to find. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 10 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 | « src/core/SkTSort.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/GrGLExtensions.cpp
===================================================================
--- src/gpu/gl/GrGLExtensions.cpp (revision 7872)
+++ src/gpu/gl/GrGLExtensions.cpp (working copy)
@@ -9,6 +9,15 @@
#include "gl/GrGLDefines.h"
#include "gl/GrGLUtil.h"
+#include "SkTSearch.h"
+#include "SkTSort.h"
+
+namespace {
+inline int extension_compare(const SkString* a, const SkString* b) {
+ return strcmp(a->c_str(), b->c_str());
+}
+}
+
bool GrGLExtensions::init(GrGLBinding binding,
GrGLGetStringProc getString,
GrGLGetStringiProc getStringi,
@@ -64,16 +73,16 @@
}
GrAssert(i == extensionCnt);
}
+ SkTSearchCompareLTFunctor<SkString, extension_compare> cmp;
+ SkTQSort(&fStrings.front(), &fStrings.back(), cmp);
return true;
}
bool GrGLExtensions::has(const char* ext) const {
- // TODO: Sort the extensions and binary search.
- int count = fStrings.count();
- for (int i = 0; i < count; ++i) {
- if (fStrings[i].equals(ext)) {
- return true;
- }
- }
- return false;
+ SkString extensionStr(ext);
+ int idx = SkTSearch<SkString, extension_compare>(&fStrings.front(),
+ fStrings.count(),
+ extensionStr,
+ sizeof(SkString));
+ return idx >= 0;
}
« no previous file with comments | « src/core/SkTSort.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698