]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
msg/async/rdma: simplify chunk::write implementation
authorChangcheng Liu <changcheng.liu@aliyun.com>
Wed, 26 Jun 2019 06:46:03 +0000 (14:46 +0800)
committerChangcheng Liu <changcheng.liu@aliyun.com>
Fri, 23 Aug 2019 02:45:22 +0000 (10:45 +0800)
Keep same logic to improve readability

Signed-off-by: Changcheng Liu <changcheng.liu@aliyun.com>
src/msg/async/rdma/Infiniband.cc

index 0d2fdebb4d370d1391db16306801441b34b7d9cc..dc82f1915f9b0511c084d27ed66a3f3f6ac5ee6f 100644 (file)
@@ -549,16 +549,10 @@ uint32_t Infiniband::MemoryManager::Chunk::read(char* buf, uint32_t len)
 
 uint32_t Infiniband::MemoryManager::Chunk::write(char* buf, uint32_t len)
 {
-  uint32_t left = bytes - offset;
-  if (left >= len) {
-    memcpy(buffer+offset, buf, len);
-    offset += len;
-    return len;
-  } else {
-    memcpy(buffer+offset, buf, left);
-    offset = bytes;
-    return left;
-  }
+  uint32_t write_len = (bytes - offset) <= len ? (bytes - offset) : len;
+  memcpy(buffer + offset, buf, write_len);
+  offset += write_len;
+  return write_len;
 }
 
 bool Infiniband::MemoryManager::Chunk::full()