From 1ee70359a199f161ce38451989a706d727954cc1 Mon Sep 17 00:00:00 2001 From: Mike Klein Date: Tue, 15 Nov 2016 10:26:44 -0500 Subject: 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 Commit-Queue: Mike Klein --- tests/FixedAllocTest.cpp | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) (limited to 'tests/FixedAllocTest.cpp') 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(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(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(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(i) == nullptr); + fallback_failed = fallback_failed || (fallback.copy(i) == nullptr); } REPORTER_ASSERT(r, !fallback_failed); -- cgit v1.2.3