]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common/bl: move bl::prepare_iovs() to .cc file
authorKefu Chai <tchaikov@gmail.com>
Fri, 15 Oct 2021 23:35:21 +0000 (07:35 +0800)
committerKefu Chai <tchaikov@gmail.com>
Fri, 15 Oct 2021 23:35:25 +0000 (07:35 +0800)
to reduce the compilation time by having a smaller header file.

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
src/common/buffer.cc
src/include/buffer.h

index 1b36b0543c7504b527f6665586b9b551b2a16528..fe9b1e09f373a3fce0e7fba3dd566bc84eaddce0 100644 (file)
@@ -2030,6 +2030,34 @@ int buffer::list::write_fd(int fd, uint64_t offset) const
 }
 #endif
 
+buffer::list::iov_vec_t buffer::list::prepare_iovs()
+{
+  iov_vec_t iovs;
+  size_t iovs_i = 0;
+  size_t index = 0;
+  uint64_t off = 0;
+  iovs.resize(_num / IOV_MAX + 1);
+  iovs[iovs_i].second.resize(
+    std::min(_num - IOV_MAX * iovs_i, (size_t)IOV_MAX));
+  iovs[iovs_i].first.first = off;
+  iovs[iovs_i].first.second = 0;
+  for (auto& bp : _buffers) {
+    if (index == IOV_MAX) {
+      iovs_i++;
+      index = 0;
+      iovs[iovs_i].first.first = off;
+      iovs[iovs_i].first.second = 0;
+      iovs[iovs_i].second.resize(
+       std::min(_num - IOV_MAX * iovs_i, (size_t)IOV_MAX));
+    }
+    iovs[iovs_i].second[index].iov_base = (void*)bp.c_str();
+    iovs[iovs_i].second[index++].iov_len = bp.length();
+    off += bp.length();
+    iovs[iovs_i].first.second += bp.length();
+  }
+  return iovs;
+}
+
 __u32 buffer::list::crc32c(__u32 crc) const
 {
   int cache_misses = 0;
index adf56400ecae07dd19121a02f364259d0cac60d7..de9ef75b3b2bcbb0a3bdd32f51f3283afc9e99e3 100644 (file)
@@ -1201,34 +1201,7 @@ struct error_code;
     using iov_vec_t =
       std::vector<std::pair<std::pair<uint64_t, uint64_t>, std::vector<iovec>>>;
 
-    iov_vec_t prepare_iovs()
-    {
-      iov_vec_t iovs;
-      size_t iovs_i = 0;
-      size_t index = 0;
-      uint64_t off = 0;
-      iovs.resize(_num / IOV_MAX + 1);
-      iovs[iovs_i].second.resize(
-       std::min(_num - IOV_MAX * iovs_i, (size_t)IOV_MAX));
-      iovs[iovs_i].first.first = off;
-      iovs[iovs_i].first.second = 0;
-      for (auto& bp : _buffers) {
-       if (index == IOV_MAX) {
-         iovs_i++;
-         index = 0;
-         iovs[iovs_i].first.first = off;
-         iovs[iovs_i].first.second = 0;
-         iovs[iovs_i].second.resize(
-           std::min(_num - IOV_MAX * iovs_i, (size_t)IOV_MAX));
-       }
-       iovs[iovs_i].second[index].iov_base = (void*)bp.c_str();
-       iovs[iovs_i].second[index++].iov_len = bp.length();
-       off += bp.length();
-       iovs[iovs_i].first.second += bp.length();
-      }
-
-      return iovs;
-    }
+    iov_vec_t prepare_iovs();
 
     uint32_t crc32c(uint32_t crc) const;
     void invalidate_crc();