From 23c16aa978199dcb9c9cc0790f2758dbceeae549 Mon Sep 17 00:00:00 2001 From: Zygo Blaxell Date: Sun, 20 Nov 2022 23:19:45 -0500 Subject: [PATCH] BeesFileRange: coalesce is not used, subtract was never implemented Less dead code to maintain. Also more Doxygen comments. Signed-off-by: Zygo Blaxell --- src/bees-types.cc | 36 ------------------------------------ src/bees.h | 20 ++++++++------------ 2 files changed, 8 insertions(+), 48 deletions(-) diff --git a/src/bees-types.cc b/src/bees-types.cc index 23c3146..2b59bb6 100644 --- a/src/bees-types.cc +++ b/src/bees-types.cc @@ -238,42 +238,6 @@ BeesFileRange::overlaps(const BeesFileRange &that) const return false; } -bool -BeesFileRange::coalesce(const BeesFileRange &that) -{ - // Let's define coalesce-with-null as identity, - // and coalesce-null-with-null as coalesced - if (!*this) { - operator=(that); - return true; - } - if (!that) { - return true; - } - - // Can't coalesce different files - if (!is_same_file(that)) return false; - - pair a(m_begin, m_end); - pair b(that.m_begin, that.m_end); - - // range a starts lower than or equal b - if (b.first < a.first) { - swap(a, b); - } - - // if b starts within a, they overlap - // (and the intersecting region is b.first..min(a.second, b.second)) - // (and the union region is a.first..max(a.second, b.second)) - if (b.first >= a.first && b.first < a.second) { - m_begin = a.first; - m_end = max(a.second, b.second); - return true; - } - - return false; -} - BeesFileRange::operator BeesBlockData() const { BEESTRACE("operator BeesBlockData " << *this); diff --git a/src/bees.h b/src/bees.h index e411c8d..c977ed5 100644 --- a/src/bees.h +++ b/src/bees.h @@ -277,35 +277,31 @@ public: bool is_same_file(const BeesFileRange &that) const; bool overlaps(const BeesFileRange &that) const; - // If file ranges overlap, extends this to include that. - // Coalesce with empty bfr = non-empty bfr - bool coalesce(const BeesFileRange &that); - - // Remove that from this, creating 0, 1, or 2 new objects - pair subtract(const BeesFileRange &that) const; - off_t begin() const { return m_begin; } off_t end() const { return m_end; } off_t size() const; - // Lazy accessors + /// @{ Lazy accessors off_t file_size() const; BeesFileId fid() const; + /// @} - // Get the fd if there is one + /// Get the fd if there is one Fd fd() const; - // Get the fd, opening it if necessary + /// Get the fd, opening it if necessary Fd fd(const shared_ptr &ctx); + /// Copy the BeesFileId but not the Fd BeesFileRange copy_closed() const; - // Is it defined? + /// Is it defined? operator bool() const { return !!m_fd || m_fid; } - // Make range larger + /// @{ Make range larger off_t grow_end(off_t delta); off_t grow_begin(off_t delta); + /// @} friend ostream & operator<<(ostream &os, const BeesFileRange &bfr); };