* MEMCACHED_HASH_MURMUR added for murmur algorithm provided.
* MEMCACHED_BEHAVIOR_RETRY_TIMEOUT added to keep connecting from looping
on timeout.
+ * gcc branch prediction optimizations
0.17 Wed Feb 27 03:33:29 PST 2008
* MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT added for connect timeout in
#include <libmemcached_config.h>
+#if !defined(__GNUC__) || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)
+#define __builtin_expect(x, expected_value) (x)
+
+#define likely(x) __builtin_expect((x),1)
+#define unlikely(x) __builtin_expect((x),0)
+
+#else
+
+#define likely(x) if((x))
+#define unlikely(x) if((x))
+
+#endif
+
#ifdef HAVE_DTRACE
#define _DTRACE_VERSION 1
#else
char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
unsigned int server_key;
- if (key_length == 0)
+ unlikely (key_length == 0)
return MEMCACHED_NO_KEY_PROVIDED;
- if (ptr->hosts == NULL || ptr->number_of_hosts == 0)
+ unlikely (ptr->hosts == NULL || ptr->number_of_hosts == 0)
return MEMCACHED_NO_SERVERS;
if ((ptr->flags & MEM_VERIFY_KEY) && (memcachd_key_test(&key, &key_length, 1) == MEMCACHED_BAD_KEY_PROVIDED))
"%s %.*s %u\r\n", verb,
(int)key_length, key,
offset);
- if (send_length >= MEMCACHED_DEFAULT_COMMAND_SIZE)
+ unlikely (send_length >= MEMCACHED_DEFAULT_COMMAND_SIZE)
return MEMCACHED_WRITE_FAILURE;
rc= memcached_do(&ptr->hosts[server_key], buffer, send_length, 1);
int flags;
flags= fcntl(ptr->fd, F_GETFL, 0);
- if (flags != -1)
+ unlikely (flags != -1)
{
(void)fcntl(ptr->fd, F_SETFL, flags | O_NONBLOCK);
}
LIBMEMCACHED_MEMCACHED_DELETE_START();
- if (key_length == 0)
+ unlikely (key_length == 0)
return MEMCACHED_NO_KEY_PROVIDED;
- if (ptr->hosts == NULL || ptr->number_of_hosts == 0)
+ unlikely (ptr->hosts == NULL || ptr->number_of_hosts == 0)
return MEMCACHED_NO_SERVERS;
server_key= memcached_generate_hash(ptr, master_key, master_key_length);
char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE];
LIBMEMCACHED_MEMCACHED_FLUSH_START();
- if (ptr->number_of_hosts == 0)
+ unlikely (ptr->number_of_hosts == 0)
return MEMCACHED_NO_SERVERS;
for (x= 0; x < ptr->number_of_hosts; x++)
WATCHPOINT_ASSERT(!(value == NULL && value_length > 0));
WATCHPOINT_ASSERT(!(value && value_length == 0));
- if (key_length == 0)
+ unlikely (key_length == 0)
return MEMCACHED_NO_KEY_PROVIDED;
- if (ptr->number_of_hosts == 0)
+ unlikely (ptr->number_of_hosts == 0)
return MEMCACHED_NO_SERVERS;
if ((ptr->flags & MEM_VERIFY_KEY) && (memcachd_key_test(&key, &key_length, 1) == MEMCACHED_BAD_KEY_PROVIDED))
send_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE,
"verbosity %u\r\n", verbosity);
- if (send_length >= MEMCACHED_DEFAULT_COMMAND_SIZE)
+ unlikely (send_length >= MEMCACHED_DEFAULT_COMMAND_SIZE)
return MEMCACHED_WRITE_FAILURE;
rc= MEMCACHED_SUCCESS;
if (world.create)
world_ptr= world.create();
+ else
+ world_ptr= NULL;
startup_ptr= (server_startup_st *)world_ptr;
servers= (memcached_server_st *)startup_ptr->servers;