aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/FixedAllocTest.cpp
diff options
context:
space:
mode:
authorGravatar Mike Klein <mtklein@chromium.org>2016-11-15 10:26:44 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-11-15 16:03:36 +0000
commit1ee70359a199f161ce38451989a706d727954cc1 (patch)
tree75c374e31b93d23ae3fbccf490f8360ee24c8b04 /tests/FixedAllocTest.cpp
parentf530586c417800d086e6e727ecb1b31e678f4183 (diff)
While we can, restrict SkFixedAlloc/SkFallbackAlloc to POD.
This trims the overhead down to a uniform 4 bytes. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4786 Change-Id: I92127a0c2d6c23a4a372eca39842e22195d2dc99 Reviewed-on: https://skia-review.googlesource.com/4786 Reviewed-by: Herb Derby <herb@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org>
Diffstat (limited to 'tests/FixedAllocTest.cpp')
-rw-r--r--tests/FixedAllocTest.cpp20
1 files changed, 4 insertions, 16 deletions
diff --git a/tests/FixedAllocTest.cpp b/tests/FixedAllocTest.cpp
index 0a00f00935..e9bae281d5 100644
--- a/tests/FixedAllocTest.cpp
+++ b/tests/FixedAllocTest.cpp
@@ -10,11 +10,10 @@
namespace {
- static int created, destroyed;
+ static int created;
struct Foo {
Foo(int X, float Y) : x(X), y(Y) { created++; }
- ~Foo() { destroyed++; }
int x;
float y;
@@ -38,21 +37,15 @@ DEF_TEST(FixedAlloc, r) {
REPORTER_ASSERT(r, foo->x == 3);
REPORTER_ASSERT(r, foo->y == 4.0f);
REPORTER_ASSERT(r, created == 1);
- REPORTER_ASSERT(r, destroyed == 0);
Foo* bar = fa.make<Foo>(8, 1.0f);
REPORTER_ASSERT(r, bar);
REPORTER_ASSERT(r, bar->x == 8);
REPORTER_ASSERT(r, bar->y == 1.0f);
REPORTER_ASSERT(r, created == 2);
- REPORTER_ASSERT(r, destroyed == 0);
fa.undo();
- REPORTER_ASSERT(r, created == 2);
- REPORTER_ASSERT(r, destroyed == 1);
}
- REPORTER_ASSERT(r, created == 2);
- REPORTER_ASSERT(r, destroyed == 2);
{
// Test alignment gurantees.
@@ -62,15 +55,10 @@ DEF_TEST(FixedAlloc, r) {
Foo* foo = fa.make<Foo>(3, 4.0f);
REPORTER_ASSERT(r, SkIsAlign4((uintptr_t)foo));
REPORTER_ASSERT(r, created == 3);
- REPORTER_ASSERT(r, destroyed == 2);
// Might as well test reset() while we're at it.
fa.reset();
- REPORTER_ASSERT(r, created == 3);
- REPORTER_ASSERT(r, destroyed == 3);
}
- REPORTER_ASSERT(r, created == 3);
- REPORTER_ASSERT(r, destroyed == 3);
}
DEF_TEST(FallbackAlloc, r) {
@@ -79,8 +67,8 @@ DEF_TEST(FallbackAlloc, r) {
SkFixedAlloc fixed(buf, sizeof(buf));
bool fixed_failed = false;
for (int i = 0; i < 32; i++) {
- // (Remember, there is some overhead to each make() call.)
- fixed_failed = fixed_failed || (fixed.make<int>(i) == nullptr);
+ // (Remember, there is some overhead to each copy() call.)
+ fixed_failed = fixed_failed || (fixed.copy(i) == nullptr);
}
REPORTER_ASSERT(r, fixed_failed);
@@ -91,7 +79,7 @@ DEF_TEST(FallbackAlloc, r) {
bool fallback_failed = false;
for (int i = 0; i < 32; i++) {
- fallback_failed = fallback_failed || (fallback.make<int>(i) == nullptr);
+ fallback_failed = fallback_failed || (fallback.copy(i) == nullptr);
}
REPORTER_ASSERT(r, !fallback_failed);