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

Unified Diff: tests/RTreeTest.cpp

Issue 617393004: BBHs: void* data -> unsigned data (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: bench Created 6 years, 3 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
Index: tests/RTreeTest.cpp
diff --git a/tests/RTreeTest.cpp b/tests/RTreeTest.cpp
index 40af5fe55b4224a77d39372bd84d6c7925183ea9..391afdf0ad11c7a8913a993078f8798680b9ea14 100644
--- a/tests/RTreeTest.cpp
+++ b/tests/RTreeTest.cpp
@@ -19,7 +19,7 @@ static const size_t NUM_QUERIES = 50;
struct DataRect {
SkRect rect;
- void* data;
+ unsigned data;
};
static SkRect random_rect(SkRandom& rand) {
@@ -37,16 +37,16 @@ static SkRect random_rect(SkRandom& rand) {
static void random_data_rects(SkRandom& rand, DataRect out[], int n) {
for (int i = 0; i < n; ++i) {
out[i].rect = random_rect(rand);
- out[i].data = reinterpret_cast<void*>(i);
+ out[i].data = (unsigned)i;
}
}
static bool verify_query(SkRect query, DataRect rects[],
- SkTDArray<void*>& found) {
+ SkTDArray<unsigned>& found) {
// TODO(mtklein): no need to do this after everything's SkRects
query.roundOut();
- SkTDArray<void*> expected;
+ SkTDArray<unsigned> expected;
// manually intersect with every rectangle
for (int i = 0; i < NUM_RECTS; ++i) {
@@ -63,18 +63,15 @@ static bool verify_query(SkRect query, DataRect rects[],
return true;
}
robertphillips 2014/10/02 12:27:35 same here
mtklein 2014/10/02 14:32:09 Turns out this sort is needed! I reopened skia:28
- // Just cast to long since sorting by the value of the void*'s was being problematic...
- SkTQSort(reinterpret_cast<long*>(expected.begin()),
- reinterpret_cast<long*>(expected.end() - 1));
- SkTQSort(reinterpret_cast<long*>(found.begin()),
- reinterpret_cast<long*>(found.end() - 1));
+ SkTQSort(expected.begin(), expected.end() -1);
+ SkTQSort(found.begin(), found.end() -1);
return found == expected;
}
static void run_queries(skiatest::Reporter* reporter, SkRandom& rand, DataRect rects[],
SkRTree& tree) {
for (size_t i = 0; i < NUM_QUERIES; ++i) {
- SkTDArray<void*> hits;
+ SkTDArray<unsigned> hits;
SkRect query = random_rect(rand);
tree.search(query, &hits);
REPORTER_ASSERT(reporter, verify_query(query, rects, hits));

Powered by Google App Engine
This is Rietveld 408576698