Fix rtree bench name bug. Unreviewed.
authorrileya@google.com <rileya@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 6 Sep 2012 13:38:53 +0000 (13:38 +0000)
committerrileya@google.com <rileya@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 6 Sep 2012 13:38:53 +0000 (13:38 +0000)
git-svn-id: http://skia.googlecode.com/svn/trunk@5411 2bbb7eff-a529-9590-31e7-b0007b416f81

bench/RTreeBench.cpp

index 759037e00ede2c59727bc1a08bf7330bd702a457..2ee6deae7b57027183f7483099626714b06980dc 100644 (file)
@@ -28,18 +28,17 @@ public:
         : INHERITED(param)
         , fTree(tree)
         , fProc(proc)
-        , fName(name)
-        , fBulkLoad(bulkLoad) { }
-protected:
-    virtual const char* onGetName() {
-        SkString str;
-        str.append("rtree_");
-        str.append(fName);
-        str.append("_build");
+        , fBulkLoad(bulkLoad) {
+        fName.append("rtree_");
+        fName.append(name);
+        fName.append("_build");
         if (fBulkLoad) {
-            str.append("_bulk");
+            fName.append("_bulk");
         }
-        return str.c_str();
+    }
+protected:
+    virtual const char* onGetName() {
+        return fName.c_str();
     }
     virtual void onDraw(SkCanvas* canvas) {
         SkRandom rand;
@@ -55,7 +54,7 @@ protected:
 private:
     SkBBoxHierarchy* fTree;
     MakeRectProc fProc;
-    const char* fName;
+    SkString fName;
     bool fBulkLoad;
     typedef SkBenchmark INHERITED;
 };
@@ -75,9 +74,14 @@ public:
         : INHERITED(param)
         , fTree(tree)
         , fProc(proc)
-        , fName(name)
         , fBulkLoad(bulkLoad)
         , fQuery(q) {
+        fName.append("rtree_");
+        fName.append(name);
+        fName.append("_query");
+        if (fBulkLoad) {
+            fName.append("_bulk");
+        }
         SkRandom rand;
         for (int j = 0; j < SkBENCHLOOP(NUM_QUERY_RECTS); ++j) {
             fTree->insert(reinterpret_cast<void*>(j), fProc(rand, j,
@@ -87,14 +91,7 @@ public:
     }
 protected:
     virtual const char* onGetName() {
-        SkString str;
-        str.append("rtree_");
-        str.append(fName);
-        str.append("_query");
-        if (fBulkLoad) {
-            str.append("_bulk");
-        }
-        return str.c_str();
+        return fName.c_str();
     }
     virtual void onDraw(SkCanvas* canvas) {
         SkRandom rand;
@@ -134,7 +131,7 @@ protected:
 private:
     SkBBoxHierarchy* fTree;
     MakeRectProc fProc;
-    const char* fName;
+    SkString fName;
     bool fBulkLoad;
     QueryType fQuery;
     typedef SkBenchmark INHERITED;