ywkaras commented on PR #11671:
URL: https://github.com/apache/trafficserver/pull/11671#issuecomment-2284905008

   A strategic issue involved here is whether we need to reduce per-transaction 
memory allocation/deallocation.  Are we assuming that newer allocators with 
per-thread arenas make it a non-issue?
   
   In a Yahoo internal plugin, I am using thread_local instances of this class 
to reduce memory allocation/deallocation:
   ```
   class GrowBuf
   {
   public:
     explicit GrowBuf(unsigned capacity = 0)
     {
       _v.reserve(capacity);
     }
   
     unsigned size() const { return _size; }
   
     const unsigned char * data() const { return _v.data(); }
   
     void clear() { _size = 0; }
   
     void push_back(unsigned char b)
     {
       if (_size < _v.size()) {
         _v[_size++] = b;
       } else {
         _v.push_back(b);
         ++_size;
       }
     }
   
     // No copy/move.
     GrowBuf(GrowBuf const &) = delete;
     GrowBuf & operator = (GrowBuf const &) = delete;
   
   private:
     std::vector<unsigned char> _v;
     unsigned _size{0};
   };
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to