Permalink
Browse files

Make sure all functions in the hot path of eg_utf8_to_utf16_general a…

…re inlined.

This gives a 33% performance boost on a micro benchmark just triggering a call
to mono_string_new.
  • Loading branch information...
1 parent 2082ed2 commit 7b4a395f24c75bb43f021106d15ad2d08439d047 @kumpera kumpera committed Mar 4, 2013
Showing with 10 additions and 3 deletions.
  1. +10 −3 eglib/src/giconv.c
View
@@ -34,6 +34,13 @@
#endif
#include <errno.h>
+#ifdef _MSC_VER
+#define FORCE_INLINE(RET_TYPE) __forceinline RET_TYPE
+#else
+#define FORCE_INLINE(RET_TYPE) inline RET_TYPE __attribute__((always_inline))
+#endif
+
+
#define UNROLL_DECODE_UTF8 0
#define UNROLL_ENCODE_UTF8 0
@@ -61,7 +68,7 @@ static int encode_utf16be (gunichar c, char *outbuf, size_t outleft);
static int decode_utf16le (char *inbuf, size_t inleft, gunichar *outchar);
static int encode_utf16le (gunichar c, char *outbuf, size_t outleft);
-static int decode_utf8 (char *inbuf, size_t inleft, gunichar *outchar);
+static FORCE_INLINE (int) decode_utf8 (char *inbuf, size_t inleft, gunichar *outchar);
static int encode_utf8 (gunichar c, char *outbuf, size_t outleft);
static int decode_latin1 (char *inbuf, size_t inleft, gunichar *outchar);
@@ -480,7 +487,7 @@ encode_utf16le (gunichar c, char *outbuf, size_t outleft)
}
}
-static int
+static FORCE_INLINE (int)
decode_utf8 (char *inbuf, size_t inleft, gunichar *outchar)
{
unsigned char *inptr = (unsigned char *) inbuf;
@@ -828,7 +835,7 @@ g_unichar_to_utf8 (gunichar c, gchar *outbuf)
return n;
}
-static int
+static FORCE_INLINE (int)
g_unichar_to_utf16 (gunichar c, gunichar2 *outbuf)
{
gunichar c2;

0 comments on commit 7b4a395

Please sign in to comment.