From dee38ca52a28e3715e4660fb5e7c709b6caac1cb Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Sat, 24 Mar 2018 20:29:56 -0500 Subject: [PATCH] buffer: kill claim_prepend Signed-off-by: Sage Weil --- src/common/buffer.cc | 13 ----------- src/include/buffer.h | 1 - src/test/bufferlist.cc | 50 ------------------------------------------ 3 files changed, 64 deletions(-) diff --git a/src/common/buffer.cc b/src/common/buffer.cc index 11196de758c47..24a5c7f0117a8 100644 --- a/src/common/buffer.cc +++ b/src/common/buffer.cc @@ -1839,19 +1839,6 @@ public: bl.last_p = bl.begin(); } - void buffer::list::claim_prepend(list& bl, unsigned int flags) - { - // steal the other guy's buffers - _len += bl._len; - if (!(flags & CLAIM_ALLOW_NONSHAREABLE)) - bl.make_shareable(); - _buffers.splice(_buffers.begin(), bl._buffers ); - bl._len = 0; - bl.last_p = bl.begin(); - // we modified _buffers - last_p = begin(); - } - void buffer::list::claim_append_piecewise(list& bl) { // steal the other guy's buffers diff --git a/src/include/buffer.h b/src/include/buffer.h index b59f271135762..0f51d9d22d8bf 100644 --- a/src/include/buffer.h +++ b/src/include/buffer.h @@ -804,7 +804,6 @@ namespace buffer CEPH_BUFFER_API { void claim(list& bl, unsigned int flags = CLAIM_DEFAULT); void claim_append(list& bl, unsigned int flags = CLAIM_DEFAULT); - void claim_prepend(list& bl, unsigned int flags = CLAIM_DEFAULT); // only for bl is bufferlist::page_aligned_appender void claim_append_piecewise(list& bl); diff --git a/src/test/bufferlist.cc b/src/test/bufferlist.cc index 4cfc4485fa2e8..bb9e91e0f271b 100644 --- a/src/test/bufferlist.cc +++ b/src/test/bufferlist.cc @@ -2106,56 +2106,6 @@ TEST(BufferList, claim_append) { EXPECT_EQ((unsigned)0, from.length()); } -TEST(BufferList, claim_prepend) { - bufferlist from; - { - bufferptr ptr(2); - from.append(ptr); - } - bufferlist to; - { - bufferptr ptr(4); - to.append(ptr); - } - EXPECT_EQ((unsigned)4, to.length()); - EXPECT_EQ((unsigned)1, to.get_num_buffers()); - to.claim_prepend(from); - EXPECT_EQ((unsigned)(2 + 4), to.length()); - EXPECT_EQ((unsigned)2, to.front().length()); - EXPECT_EQ((unsigned)4, to.back().length()); - EXPECT_EQ((unsigned)2, to.get_num_buffers()); - EXPECT_EQ((unsigned)0, from.get_num_buffers()); - EXPECT_EQ((unsigned)0, from.length()); -} - -TEST(BufferList, claim_prepend_misc) { - bufferlist src_buf; - bufferlist dest_buf; - - bufferlist b1; - b1.append("12345", 5); - bufferlist b2; - b2.append("123456", 6); - bufferlist b3; - b3.append("1234567", 7); - - EXPECT_EQ(5u, b1.length()); - EXPECT_EQ(6u, b2.length()); - EXPECT_EQ(7u, b3.length()); - src_buf.claim_append(b1); - src_buf.claim_append(b2); - EXPECT_EQ((unsigned)(5+6), src_buf.length()); - src_buf.splice(0, 3); - EXPECT_EQ((unsigned)(5-3), src_buf.front().length()); - EXPECT_EQ((unsigned)(11-3), src_buf.length()); - src_buf.claim_prepend(b3); - EXPECT_EQ((unsigned)(8+7), src_buf.length()); - EXPECT_EQ(0u, b3.get_num_buffers()); - EXPECT_EQ(0u, b3.length()); - src_buf.copy(0, src_buf.length(), dest_buf); - EXPECT_EQ(3u, dest_buf.get_num_buffers()); -} - TEST(BufferList, claim_append_piecewise) { bufferlist bl, t, dst; auto a = bl.get_page_aligned_appender(4); -- 2.39.5