Moved to using vector send for writes (lowers function call count).
authorBrian Aker <brian@gaz>
Fri, 2 Apr 2010 04:17:58 +0000 (21:17 -0700)
committerBrian Aker <brian@gaz>
Fri, 2 Apr 2010 04:17:58 +0000 (21:17 -0700)
libmemcached/io.c
libmemcached/io.h

index c72aaa277e933584e4c570a3bf422b017c3f4899..616ad497b9798147229106c4c459788ccb11f913 100644 (file)
@@ -326,36 +326,8 @@ memcached_return_t memcached_io_read(memcached_server_write_instance_st ptr,
   return MEMCACHED_SUCCESS;
 }
 
-ssize_t memcached_io_writev(memcached_server_write_instance_st ptr,
-                            struct __write_vector_st *vector,
-                            size_t number_of, bool with_flush)
-{
-  ssize_t total= 0;
-
-  for (size_t x= 0; x < number_of; x++, vector++)
-  {
-    ssize_t returnable;
-
-    if ((returnable= memcached_io_write(ptr, vector->buffer, vector->length, false)) == -1)
-    {
-      return -1;
-    }
-    total+= returnable;
-  }
-
-  if (with_flush)
-  {
-    if (memcached_io_write(ptr, NULL, 0, true) == -1)
-    {
-      return -1;
-    }
-  }
-
-  return total;
-}
-
-ssize_t memcached_io_write(memcached_server_write_instance_st ptr,
-                           const void *buffer, size_t length, bool with_flush)
+static ssize_t _io_write(memcached_server_write_instance_st ptr,
+                         const void *buffer, size_t length, bool with_flush)
 {
   size_t original_length;
   const char* buffer_ptr;
@@ -431,6 +403,41 @@ ssize_t memcached_io_write(memcached_server_write_instance_st ptr,
   return (ssize_t) original_length;
 }
 
+ssize_t memcached_io_write(memcached_server_write_instance_st ptr,
+                           const void *buffer, size_t length, bool with_flush)
+{
+  return _io_write(ptr, buffer, length, with_flush);
+}
+
+ssize_t memcached_io_writev(memcached_server_write_instance_st ptr,
+                            const struct __write_vector_st *vector,
+                            size_t number_of, bool with_flush)
+{
+  ssize_t total= 0;
+
+  for (size_t x= 0; x < number_of; x++, vector++)
+  {
+    ssize_t returnable;
+
+    if ((returnable= _io_write(ptr, vector->buffer, vector->length, false)) == -1)
+    {
+      return -1;
+    }
+    total+= returnable;
+  }
+
+  if (with_flush)
+  {
+    if (memcached_io_write(ptr, NULL, 0, true) == -1)
+    {
+      return -1;
+    }
+  }
+
+  return total;
+}
+
+
 memcached_return_t memcached_io_close(memcached_server_write_instance_st ptr)
 {
   if (ptr->fd == -1)
index 89f3d477e308f5c43383a82d8078028c6101195b..b614d818ccc601ba3bc75de0c4e373ef00deee58 100644 (file)
@@ -49,7 +49,7 @@ struct __write_vector_st
 
 LIBMEMCACHED_LOCAL
 ssize_t memcached_io_writev(memcached_server_write_instance_st ptr,
-                            struct __write_vector_st *vector,
+                            const struct __write_vector_st *vector,
                             size_t number_of, bool with_flush);
 
 LIBMEMCACHED_LOCAL