diff options
author | 2013-07-23 17:26:34 +0000 | |
---|---|---|
committer | 2013-07-23 17:26:34 +0000 | |
commit | 434251f87292808c1c461e48dba5d22735e74f97 (patch) | |
tree | c30beda131d9ebf56d3e7d1bd382f57d7349340f /bench | |
parent | 88876dbac8338f5d9ff81a1f0ac03880788e2bea (diff) |
refactor duplication (shouldSkip and skip_name) into a utility function
R=caryclark@google.com, reed@google.com
Review URL: https://codereview.chromium.org/19807005
git-svn-id: http://skia.googlecode.com/svn/trunk@10280 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'bench')
-rw-r--r-- | bench/benchmain.cpp | 35 |
1 files changed, 2 insertions, 33 deletions
diff --git a/bench/benchmain.cpp b/bench/benchmain.cpp index c0f6da90ec..1ace7d108a 100644 --- a/bench/benchmain.cpp +++ b/bench/benchmain.cpp @@ -22,6 +22,7 @@ class GrContext; #include "SkBenchLogger.h" #include "SkBenchmark.h" #include "SkCanvas.h" +#include "SkCommandLineFlags.h" #include "SkDeferredCanvas.h" #include "SkDevice.h" #include "SkColorPriv.h" @@ -270,38 +271,6 @@ static int findConfig(const char config[]) { return -1; } -static bool skip_name(const SkTDArray<const char*> array, const char name[]) { - // FIXME: this duplicates the logic in skia_test.cpp, gmmain.cpp -- consolidate - int count = array.count(); - size_t testLen = strlen(name); - bool anyExclude = count == 0; - for (int i = 0; i < array.count(); ++i) { - const char* matchName = array[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; -} - static void help() { SkString configsStr; static const size_t kConfigCount = SK_ARRAY_COUNT(gConfigs); @@ -771,7 +740,7 @@ int tool_main(int argc, char** argv) { } // only run benchmarks if their name contains matchStr - if (skip_name(fMatches, bench->getName())) { + if (SkCommandLineFlags::ShouldSkip(fMatches, bench->getName())) { continue; } |