Index: src/record/SkRecord.h |
diff --git a/src/record/SkRecord.h b/src/record/SkRecord.h |
index b1e4ae24f8da69b5e60aecad189573dbd448c9fd..5d5c122c3ab8ee40b4c6a80c13b309c1b7e97bc5 100644 |
--- a/src/record/SkRecord.h |
+++ b/src/record/SkRecord.h |
@@ -77,7 +77,7 @@ public: |
} |
fTypes[fCount] = T::kType; |
- return fRecords[fCount++].set(this->alloc<T>()); |
+ return fRecords[fCount++].set(this->allocCommand<T>()); |
} |
// Replace the i-th command with a new command of type T. |
@@ -91,7 +91,7 @@ public: |
this->mutate(i, destroyer); |
fTypes[i] = T::kType; |
- return fRecords[i].set(this->alloc<T>()); |
+ return fRecords[i].set(this->allocCommand<T>()); |
} |
// Replace the i-th command with a new command of type T. |
@@ -105,7 +105,7 @@ public: |
SkASSERT(proofOfAdoption == fRecords[i].ptr<Existing>()); |
fTypes[i] = T::kType; |
- return fRecords[i].set(this->alloc<T>()); |
+ return fRecords[i].set(this->allocCommand<T>()); |
} |
private: |
@@ -162,6 +162,16 @@ private: |
uint8_t fType; |
}; |
+ template <typename T> |
+ T* allocCommand() { |
+ struct AddChar : public T { char unused; }; |
+ if (sizeof(AddChar) == sizeof(char)) { |
+ // T is an empty struct. |
+ return NULL; |
+ } |
+ return this->alloc<T>(); |
+ } |
bungeman-skia
2014/05/07 14:35:24
I understand what you're doing here, but eck. Can
mtklein
2014/05/07 15:27:43
Done. Leaving rearranging / renaming the traits f
|
+ |
// An untyped pointer to some bytes in fAlloc. This is the interface for polymorphic dispatch: |
// visit() and mutate() work with the parallel fTypes array to do the work of a vtable. |
struct Record { |