I'm working on some code that's much faster when compiled by GCC than by Clang
because GCC inlines more aggressively.  Using SK_ATTRIBUTE(always_inline) on
the appropriate methods narrows the performance gap considerably.

This should work for MSVC, GCC, and Clang, otherwise falling back to "inline".


Review URL:

git-svn-id: 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/core/SkPostConfig.h b/core/SkPostConfig.h
index 1aff899..9ba199f 100644
--- a/core/SkPostConfig.h
+++ b/core/SkPostConfig.h
@@ -379,6 +379,18 @@
     #define SK_ATTR_DEPRECATED(msg) SK_ATTRIBUTE(deprecated)
+// If your judgment is better than the compiler's (i.e. you've profiled it),
+// you can use SK_ALWAYS_INLINE to force inlining. E.g.
+//     inline void someMethod() { ... }             // may not be inlined
+//     SK_ALWAYS_INLINE void someMethod() { ... }   // should always be inlined
+#if !defined(SK_ALWAYS_INLINE)
+#  if defined(SK_BUILD_FOR_WIN)
+#    define SK_ALWAYS_INLINE __forceinline
+#  else
+#    define SK_ALWAYS_INLINE SK_ATTRIBUTE(always_inline) inline
+#  endif
 #if defined(__clang__) || defined(__GNUC__)