fix pathops_unittest test strings
Using std::string is tons faster than SkString;
multiple callers to std::string don't run into
thread contention but SkString does.
R=csmartdalton@google.com
Change-Id: I0357c6a9c73856bfffbb76e65c275acdfe7d8159
Reviewed-on: https://skia-review.googlesource.com/13471
Reviewed-by: Chris Dalton <csmartdalton@google.com>
Commit-Queue: Cary Clark <caryclark@google.com>
diff --git a/tests/PathOpsExtendedTest.cpp b/tests/PathOpsExtendedTest.cpp
index 8f24adf..c668963 100644
--- a/tests/PathOpsExtendedTest.cpp
+++ b/tests/PathOpsExtendedTest.cpp
@@ -21,6 +21,17 @@
#include <sys/sysctl.h>
#endif
+// std::to_string isn't implemented on android
+#include <sstream>
+
+template <typename T>
+std::string std_to_string(T value)
+{
+ std::ostringstream os ;
+ os << value ;
+ return os.str() ;
+}
+
bool OpDebug(const SkPath& one, const SkPath& two, SkPathOp op, SkPath* result
SkDEBUGPARAMS(bool skipAssert)
SkDEBUGPARAMS(const char* testName));
@@ -179,7 +190,7 @@
state->fSerialNo[8] = '\0';
SkDebugf("%s\n", state->fSerialNo);
if (strcmp(state->fSerialNo, state->fKey) == 0) {
- SkDebugf("%s\n", state->fPathStr);
+ SkDebugf("%s\n", state->fPathStr.c_str());
}
#endif
}
@@ -371,8 +382,9 @@
static int testNumber = 55;
static const char* testName = "pathOpTest";
-static void appendTestName(const char* nameSuffix, SkString& out) {
- out.appendf("%s%d", testName, testNumber);
+static void appendTestName(const char* nameSuffix, std::string& out) {
+ out += testName;
+ out += std_to_string(testNumber);
++testNumber;
if (nameSuffix) {
out.append(nameSuffix);
@@ -380,7 +392,7 @@
}
static void appendTest(const char* pathStr, const char* pathPrefix, const char* nameSuffix,
- const char* testFunction, bool twoPaths, SkString& out) {
+ const char* testFunction, bool twoPaths, std::string& out) {
#if 0
out.append("\n<div id=\"");
appendTestName(nameSuffix, out);
@@ -406,7 +418,9 @@
if (pathPrefix) {
out.append(pathPrefix);
}
- out.appendf("%s %s\n}\n\n", pathStr, testFunction);
+ out += pathStr;
+ out += " ";
+ out += testFunction;
#if 0
out.append("static void (*firstTest)() = ");
appendTestName(nameSuffix, out);
@@ -440,7 +454,7 @@
int result = comparePaths(state.fReporter, nullptr, path, out, *state.fBitmap);
if (result) {
SkAutoMutexAcquire autoM(simplifyDebugOut);
- SkString str;
+ std::string str;
const char* pathPrefix = nullptr;
const char* nameSuffix = nullptr;
if (fillType == SkPath::kEvenOdd_FillType) {