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

Unified Diff: tools/flags/SkCommandLineFlags.cpp

Issue 19807005: refactor duplication (shouldSkip and skip_name) into a utility function (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Forced linking is required, shouldn't have removed it Created 7 years, 5 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 | « tools/flags/SkCommandLineFlags.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/flags/SkCommandLineFlags.cpp
diff --git a/tools/flags/SkCommandLineFlags.cpp b/tools/flags/SkCommandLineFlags.cpp
index ed8db8e7055fed0c9dccbd786388eb53338dfc61..b088b4e4d38ec6675bd4c64c3b779b0cc5313975 100644
--- a/tools/flags/SkCommandLineFlags.cpp
+++ b/tools/flags/SkCommandLineFlags.cpp
@@ -303,3 +303,34 @@ void SkCommandLineFlags::Parse(int argc, char** argv) {
exit(0);
}
}
+
+bool SkCommandLineFlags::ShouldSkip(const SkTDArray<const char*>& strings, const char* name) {
+ int count = strings.count();
+ size_t testLen = strlen(name);
+ bool anyExclude = count == 0;
+ for (int i = 0; i < strings.count(); ++i) {
+ const char* matchName = strings[i];
+ size_t matchLen = strlen(matchName);
+ bool matchExclude, matchStart, matchEnd;
+ if ((matchExclude = matchName[0] == '~')) {
+ anyExclude = true;
+ matchName++;
+ matchLen--;
+ }
+ if ((matchStart = matchName[0] == '^')) {
+ matchName++;
+ matchLen--;
+ }
+ if ((matchEnd = matchName[matchLen - 1] == '$')) {
+ matchLen--;
+ }
+ if (matchStart ? (!matchEnd || matchLen == testLen)
+ && strncmp(name, matchName, matchLen) == 0
+ : matchEnd ? matchLen <= testLen
+ && strncmp(name + testLen - matchLen, matchName, matchLen) == 0
+ : strstr(name, matchName) != 0) {
+ return matchExclude;
+ }
+ }
+ return !anyExclude;
+}
« no previous file with comments | « tools/flags/SkCommandLineFlags.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698