]> granicus.if.org Git - pgbouncer/commitdiff
drop too clever optimizations from system.h
authorMarko Kreen <markokr@gmail.com>
Wed, 25 Jun 2008 15:06:22 +0000 (15:06 +0000)
committerMarko Kreen <markokr@gmail.com>
Wed, 25 Jun 2008 15:06:22 +0000 (15:06 +0000)
include/system.h
src/hash.c

index a9151a6139c8f2318f2552ec746f3b80bfdd61ad..eb9ef9881e96daa5634c03bb274335d9c8af6dd9 100644 (file)
@@ -161,51 +161,4 @@ const char *basename(const char *path);
 
 void change_user(const char *user);
 
-/*
- * memcpy() optimization - improves hash.c.
- *
- * GCC can optimize fixed-length memcpys but not variable-length ones.
- * For short variable-length memcpys its faster to do dumb inlined copy
- * than call out to libc.
- */
-
-#if defined(__GNUC__) && (__GNUC__ >= 3)
-
-static inline void *_inline_memcpy(void *dst_, const void *src_, size_t len)
-{
-       const uint8_t *src = src_;
-       uint8_t *dst = dst_;
-       while (len--)
-               *dst++ = *src++;
-       return dst_;
-}
-
-static inline void *_own_memcpy(void *dst, const void *src, size_t len)
-{
-       if (!__builtin_constant_p(len)
-           && __builtin_constant_p(len < 16)
-           && len < 16)
-               return _inline_memcpy(dst, src, len);
-       else
-               return memcpy(dst, src, len);
-}
-
-#undef memcpy
-#define memcpy(d, s, n) _own_memcpy(d, s, n)
-
-#endif
-
-/*
- * strcmp() optimization - compare first char inline.
- */
-
-static inline int _inline_strcmp(const char *a, const char *b)
-{
-       if ((*a - *b) != 0)
-               return (*a - *b);
-       return strcmp(a, b);
-}
-
-#undef strcmp
-#define strcmp(a, b) _inline_strcmp(a, b)
 
index bb60ceced0e7860c2d184228d843d75aa21f7d18..ff055960478b0432ec3674330583421a5ff89a77 100644 (file)
        c ^= b; c -= rot(b,24); \
 } while (0)
 
+/*
+ * GCC does not know how to optimize short variable-length copies.
+ * Its faster to do dumb inlined copy than call out to libc.
+ */
+static inline void simple_memcpy(void *dst_, const void *src_, size_t len)
+{
+       const uint8_t *src = src_;
+       uint8_t *dst = dst_;
+       while (len--)
+               *dst++ = *src++;
+}
+
 /* short version - let compiler worry about memory access */
 uint32_t lookup3_hash(const void *data, size_t len)
 {
@@ -63,7 +75,7 @@ uint32_t lookup3_hash(const void *data, size_t len)
        }
 
        buf[0] = buf[1] = buf[2] = 0;
-       memcpy(buf, p, len);
+       simple_memcpy(buf, p, len);
        a += buf[0];
        b += buf[1];
        c += buf[2];