Add SK_ALWAYS_INLINE.

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".

BUG=
R=reed@google.com

Review URL: https://codereview.chromium.org/83333005

git-svn-id: http://skia.googlecode.com/svn/trunk@12364 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
mtklein@google.com 2013-11-22 16:56:22 +00:00
parent 46a9bb8d71
commit 1950d5f58f

View File

@ -379,6 +379,18 @@
#define SK_ATTR_DEPRECATED(msg) SK_ATTRIBUTE(deprecated)
#endif
// 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
#endif
//////////////////////////////////////////////////////////////////////
#if defined(__clang__) || defined(__GNUC__)