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

Unified Diff: tests/FunctionTest.cpp

Issue 1048243002: small-object optimization for SkFunction (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: windows Created 5 years, 9 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
« no previous file with comments | « src/utils/SkTLogic.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/FunctionTest.cpp
diff --git a/tests/FunctionTest.cpp b/tests/FunctionTest.cpp
index 5611b80776cca62977a64ae30103e780a41c1404..6fffcbd43ae92d5699aa7d3194a68135b1b2078c 100644
--- a/tests/FunctionTest.cpp
+++ b/tests/FunctionTest.cpp
@@ -9,6 +9,7 @@
#include "Test.h"
static void test_add_five(skiatest::Reporter* r, SkFunction<int(int)>&& f) {
+ REPORTER_ASSERT(r, f(3) == 8);
REPORTER_ASSERT(r, f(4) == 9);
}
@@ -24,4 +25,9 @@ DEF_TEST(Function, r) {
test_add_five(r, SkFunction<int(int)>(&add_five));
test_add_five(r, SkFunction<int(int)>(AddFive()));
test_add_five(r, SkFunction<int(int)>([](int x) { return x + 5; }));
+
+ // AddFive and the lambda above are both small enough to test small-object optimization.
+ // Now test a lambda that's much too large for the small-object optimization.
+ int a = 1, b = 1, c = 1, d = 1, e = 1;
+ test_add_five(r, SkFunction<int(int)>([&](int x) { return x + a + b + c + d + e; }));
}
« no previous file with comments | « src/utils/SkTLogic.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698