From 4fe2c2018a0de05855ca3e24efeac5f48c48ec48 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Fri, 2 Nov 2018 21:04:15 +0800 Subject: [PATCH] common: remove redundant implementations this change reverts cac1d6f936c40003c5231d1051feb51198252715 Signed-off-by: Kefu Chai --- src/common/buffer.cc | 97 -------------------------------------------- src/include/buffer.h | 44 +++----------------- 2 files changed, 5 insertions(+), 136 deletions(-) diff --git a/src/common/buffer.cc b/src/common/buffer.cc index 5efcf10a482..b96bd80f4b6 100644 --- a/src/common/buffer.cc +++ b/src/common/buffer.cc @@ -782,11 +782,6 @@ using namespace ceph; return _len + _off; } - void buffer::ptr::copy_in(unsigned o, unsigned l, const char *src) - { - copy_in(o, l, src, true); - } - void buffer::ptr::copy_in(unsigned o, unsigned l, const char *src, bool crc_reset) { ceph_assert(_raw); @@ -798,11 +793,6 @@ using namespace ceph; maybe_inline_memcpy(dest, src, l, 64); } - void buffer::ptr::zero() - { - zero(true); - } - void buffer::ptr::zero(bool crc_reset) { if (crc_reset) @@ -810,11 +800,6 @@ using namespace ceph; memset(c_str(), 0, _len); } - void buffer::ptr::zero(unsigned o, unsigned l) - { - zero(o, l, true); - } - void buffer::ptr::zero(unsigned o, unsigned l, bool crc_reset) { ceph_assert(o+l <= _len); @@ -1074,78 +1059,6 @@ using namespace ceph; : iterator_impl(l, o, ip, po) {} - void buffer::list::iterator::advance(unsigned o) - { - buffer::list::iterator_impl::advance(o); - } - - void buffer::list::iterator::seek(unsigned o) - { - buffer::list::iterator_impl::seek(o); - } - - char buffer::list::iterator::operator*() - { - if (p == ls->end()) { - throw end_of_buffer(); - } - return (*p)[p_off]; - } - - buffer::list::iterator& buffer::list::iterator::operator++() - { - buffer::list::iterator_impl::operator++(); - return *this; - } - - buffer::ptr buffer::list::iterator::get_current_ptr() - { - if (p == ls->end()) { - throw end_of_buffer(); - } - return ptr(*p, p_off, p->length() - p_off); - } - - void buffer::list::iterator::copy(unsigned len, char *dest) - { - return buffer::list::iterator_impl::copy(len, dest); - } - - void buffer::list::iterator::copy(unsigned len, ptr &dest) - { - return buffer::list::iterator_impl::copy_deep(len, dest); - } - - void buffer::list::iterator::copy_deep(unsigned len, ptr &dest) - { - buffer::list::iterator_impl::copy_deep(len, dest); - } - - void buffer::list::iterator::copy_shallow(unsigned len, ptr &dest) - { - buffer::list::iterator_impl::copy_shallow(len, dest); - } - - void buffer::list::iterator::copy(unsigned len, list &dest) - { - buffer::list::iterator_impl::copy(len, dest); - } - - void buffer::list::iterator::copy(unsigned len, std::string &dest) - { - buffer::list::iterator_impl::copy(len, dest); - } - - void buffer::list::iterator::copy_all(list &dest) - { - buffer::list::iterator_impl::copy_all(dest); - } - - void buffer::list::iterator::copy_in(unsigned len, const char *src) - { - copy_in(len, src, true); - } - // copy data in void buffer::list::iterator::copy_in(unsigned len, const char *src, bool crc_reset) { @@ -1207,11 +1120,6 @@ using namespace ceph; other.last_p = other.begin(); } - bool buffer::list::contents_equal(buffer::list& other) - { - return static_cast(this)->contents_equal(other); - } - bool buffer::list::contents_equal(const ceph::buffer::list& other) const { if (length() != other.length()) @@ -1571,11 +1479,6 @@ using namespace ceph; return last_p.copy(len, dest); } - void buffer::list::copy_in(unsigned off, unsigned len, const char *src) - { - copy_in(off, len, src, true); - } - void buffer::list::copy_in(unsigned off, unsigned len, const char *src, bool crc_reset) { if (off + len > length()) diff --git a/src/include/buffer.h b/src/include/buffer.h index 43820d42f2b..567a3492a51 100644 --- a/src/include/buffer.h +++ b/src/include/buffer.h @@ -364,12 +364,9 @@ namespace buffer CEPH_BUFFER_API { return append(s.data(), s.length()); } #endif // __cplusplus >= 201703L - void copy_in(unsigned o, unsigned l, const char *src); - void copy_in(unsigned o, unsigned l, const char *src, bool crc_reset); - void zero(); - void zero(bool crc_reset); - void zero(unsigned o, unsigned l); - void zero(unsigned o, unsigned l, bool crc_reset); + void copy_in(unsigned o, unsigned l, const char *src, bool crc_reset = true); + void zero(bool crc_reset = true); + void zero(unsigned o, unsigned l, bool crc_reset = true); unsigned append_zeros(unsigned l); #ifdef HAVE_SEASTAR @@ -485,38 +482,9 @@ namespace buffer CEPH_BUFFER_API { iterator() = default; iterator(bl_t *l, unsigned o=0); iterator(bl_t *l, unsigned o, list_iter_t ip, unsigned po); - - void advance(int o) = delete; - void advance(unsigned o); - void advance(size_t o) { advance(static_cast(o)); } - - void seek(unsigned o); - using iterator_impl::operator*; - char operator*(); - iterator& operator++(); - ptr get_current_ptr(); - - // copy data out - void copy(unsigned len, char *dest); - // deprecated, use copy_deep() - void copy(unsigned len, ptr &dest) __attribute__((deprecated)); - void copy_deep(unsigned len, ptr &dest); - void copy_shallow(unsigned len, ptr &dest); - void copy(unsigned len, list &dest); - void copy(unsigned len, std::string &dest); - void copy_all(list &dest); - // copy data in - void copy_in(unsigned len, const char *src); - void copy_in(unsigned len, const char *src, bool crc_reset); + void copy_in(unsigned len, const char *src, bool crc_reset = true); void copy_in(unsigned len, const list& otherl); - - bool operator==(const iterator& rhs) const { - return bl == rhs.bl && off == rhs.off; - } - bool operator!=(const iterator& rhs) const { - return bl != rhs.bl || off != rhs.off; - } }; class contiguous_appender { @@ -784,7 +752,6 @@ namespace buffer CEPH_BUFFER_API { return _len; } - bool contents_equal(buffer::list& other); bool contents_equal(const buffer::list& other) const; bool is_provided_buffer(const char *dst) const; @@ -893,8 +860,7 @@ namespace buffer CEPH_BUFFER_API { void copy(unsigned off, unsigned len, char *dest) const; void copy(unsigned off, unsigned len, list &dest) const; void copy(unsigned off, unsigned len, std::string& dest) const; - void copy_in(unsigned off, unsigned len, const char *src); - void copy_in(unsigned off, unsigned len, const char *src, bool crc_reset); + void copy_in(unsigned off, unsigned len, const char *src, bool crc_reset = true); void copy_in(unsigned off, unsigned len, const list& src); void append(char c); -- 2.39.5