You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2020/07/08 15:31:04 UTC

[trafficserver] 01/02: Remove unused functions of IOBuffer

This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

commit 939a260a8c159eb7bb801cf5b0e7f82de94f32ed
Author: Masaori Koshiba <ma...@apache.org>
AuthorDate: Fri Nov 8 10:49:10 2019 +0900

    Remove unused functions of IOBuffer
    
    (cherry picked from commit 4edbda64b9ab555e541a96309ae43d2ea1484cd7)
---
 iocore/eventsystem/IOBuffer.cc  | 42 -----------------------------------------
 iocore/eventsystem/I_IOBuffer.h | 40 ---------------------------------------
 iocore/eventsystem/P_IOBuffer.h | 34 ---------------------------------
 3 files changed, 116 deletions(-)

diff --git a/iocore/eventsystem/IOBuffer.cc b/iocore/eventsystem/IOBuffer.cc
index ad95f42..d88f332 100644
--- a/iocore/eventsystem/IOBuffer.cc
+++ b/iocore/eventsystem/IOBuffer.cc
@@ -64,26 +64,6 @@ init_buffer_allocators(int iobuffer_advice)
 // MIOBuffer
 //
 int64_t
-MIOBuffer::remove_append(IOBufferReader *r)
-{
-  int64_t l = 0;
-  while (r->block) {
-    Ptr<IOBufferBlock> b = r->block;
-    r->block             = r->block->next;
-    b->_start += r->start_offset;
-    if (b->start() >= b->end()) {
-      r->start_offset = -r->start_offset;
-      continue;
-    }
-    r->start_offset = 0;
-    l += b->read_avail();
-    append_block(b.get());
-  }
-  r->mbuf->_writer = nullptr;
-  return l;
-}
-
-int64_t
 MIOBuffer::write(const void *abuf, int64_t alen)
 {
   const char *buf = static_cast<const char *>(abuf);
@@ -154,28 +134,6 @@ MIOBuffer::write(IOBufferBlock const *b, int64_t alen, int64_t offset)
   return alen - len;
 }
 
-int64_t
-MIOBuffer::puts(char *s, int64_t len)
-{
-  char *pc = end();
-  char *pb = s;
-  while (pc < buf_end()) {
-    if (len-- <= 0) {
-      return -1;
-    }
-    if (!*pb || *pb == '\n') {
-      int64_t n = static_cast<int64_t>(pb - s);
-      memcpy(end(), s, n + 1); // Up to and including '\n'
-      end()[n + 1] = 0;
-      fill(n + 1);
-      return n + 1;
-    }
-    pc++;
-    pb++;
-  }
-  return 0;
-}
-
 bool
 MIOBuffer::is_max_read_avail_more_than(int64_t size)
 {
diff --git a/iocore/eventsystem/I_IOBuffer.h b/iocore/eventsystem/I_IOBuffer.h
index 313e13f..6173006 100644
--- a/iocore/eventsystem/I_IOBuffer.h
+++ b/iocore/eventsystem/I_IOBuffer.h
@@ -441,9 +441,6 @@ public:
   */
   void set(IOBufferData *d, int64_t len = 0, int64_t offset = 0);
   void set_internal(void *b, int64_t len, int64_t asize_index);
-  void realloc_set_internal(void *b, int64_t buf_size, int64_t asize_index);
-  void realloc(void *b, int64_t buf_size);
-  void realloc(int64_t i);
 
   /**
     Frees the IOBufferBlock object and its underlying memory.
@@ -1000,8 +997,6 @@ public:
   */
   int64_t write(IOBufferChain const *chain, int64_t len = INT64_MAX, int64_t offset = 0);
 
-  int64_t remove_append(IOBufferReader *);
-
   /**
     Returns a pointer to the first writable block on the block chain.
     Returns nullptr if there are not currently any writable blocks on the
@@ -1077,16 +1072,6 @@ public:
   int64_t block_size();
 
   /**
-    Returns the default data block size for this buffer.
-
-  */
-  int64_t
-  total_size()
-  {
-    return block_size();
-  }
-
-  /**
     Returns true if amount of the data outstanding on the buffer exceeds
     the watermark.
 
@@ -1119,7 +1104,6 @@ public:
   {
     return current_write_avail() <= water_mark;
   }
-  void set_size_index(int64_t size);
 
   /**
     Allocates a new IOBuffer reader and sets it's its 'accessor' field
@@ -1167,16 +1151,9 @@ public:
   void alloc(int64_t i = default_large_iobuffer_size);
   void append_block_internal(IOBufferBlock *b);
   int64_t write(IOBufferBlock const *b, int64_t len, int64_t offset);
-  int64_t puts(char *buf, int64_t len);
 
   // internal interface
 
-  bool
-  empty()
-  {
-    return !_writer;
-  }
-
   /**
     Get the maximum amount of available data across all of the readers.
     If there're no allocated reader, return available data size of current writer.
@@ -1238,17 +1215,6 @@ public:
     water_mark = 0;
   }
 
-  void
-  realloc(int64_t i)
-  {
-    _writer->realloc(i);
-  }
-  void
-  realloc(void *b, int64_t buf_size)
-  {
-    _writer->realloc(b, buf_size);
-  }
-
   int64_t size_index;
 
   /**
@@ -1296,12 +1262,6 @@ struct MIOBufferAccessor {
     return mbuf->block_size();
   }
 
-  int64_t
-  total_size() const
-  {
-    return block_size();
-  }
-
   void reader_for(IOBufferReader *abuf);
   void reader_for(MIOBuffer *abuf);
   void writer_for(MIOBuffer *abuf);
diff --git a/iocore/eventsystem/P_IOBuffer.h b/iocore/eventsystem/P_IOBuffer.h
index 5d77c56..00cd7f0 100644
--- a/iocore/eventsystem/P_IOBuffer.h
+++ b/iocore/eventsystem/P_IOBuffer.h
@@ -426,34 +426,6 @@ IOBufferBlock::set(IOBufferData *d, int64_t len, int64_t offset)
   _buf_end = buf() + d->block_size();
 }
 
-TS_INLINE void
-IOBufferBlock::realloc_set_internal(void *b, int64_t buf_size, int64_t asize_index)
-{
-  int64_t data_size = size();
-  memcpy(b, _start, size());
-  dealloc();
-  set_internal(b, buf_size, asize_index);
-  _end = _start + data_size;
-}
-
-TS_INLINE void
-IOBufferBlock::realloc(void *b, int64_t buf_size)
-{
-  realloc_set_internal(b, buf_size, BUFFER_SIZE_NOT_ALLOCATED);
-}
-
-TS_INLINE void
-IOBufferBlock::realloc(int64_t i)
-{
-  if ((i == data->_size_index) || (i >= (int64_t)countof(ioBufAllocator))) {
-    return;
-  }
-
-  ink_release_assert(i > data->_size_index && i != BUFFER_SIZE_NOT_ALLOCATED);
-  void *b = ioBufAllocator[i].alloc_void();
-  realloc_set_internal(b, BUFFER_SIZE_FOR_INDEX(i), i);
-}
-
 //////////////////////////////////////////////////////////////////
 //
 //  class IOBufferReader --
@@ -1052,12 +1024,6 @@ MIOBuffer::dealloc_all_readers()
 }
 
 TS_INLINE void
-MIOBuffer::set_size_index(int64_t size)
-{
-  size_index = iobuffer_size_to_index(size);
-}
-
-TS_INLINE void
 MIOBufferAccessor::reader_for(MIOBuffer *abuf)
 {
   mbuf = abuf;