Detected by Coverity Scan.
const SBuf::size_type SBuf::npos;
const SBuf::size_type SBuf::maxSize;
-SBuf::SBuf()
- : store_(GetStorePrototype()), off_(0), len_(0)
+SBuf::SBuf() : store_(GetStorePrototype())
{
debugs(24, 8, id << " created");
++stats.alloc;
++stats.live;
}
-SBuf::SBuf(const std::string &s)
- : store_(GetStorePrototype()), off_(0), len_(0)
+SBuf::SBuf(const std::string &s) : store_(GetStorePrototype())
{
debugs(24, 8, id << " created from std::string");
lowAppend(s.data(),s.length());
++stats.live;
}
-SBuf::SBuf(const char *S, size_type n)
- : store_(GetStorePrototype()), off_(0), len_(0)
+SBuf::SBuf(const char *S, size_type n) : store_(GetStorePrototype())
{
append(S,n);
++stats.alloc;
++stats.live;
}
-SBuf::SBuf(const char *S)
- : store_(GetStorePrototype()), off_(0), len_(0)
+SBuf::SBuf(const char *S) : store_(GetStorePrototype())
{
append(S,npos);
++stats.alloc;
protected:
SBufIterator(const SBuf &, size_type);
- const char *iter;
+ const char *iter = nullptr;
};
/** Reverse input const_iterator for SBufs
/// create an empty (zero-size) SBuf
SBuf();
SBuf(const SBuf &S);
-#if __cplusplus >= 201103L
SBuf(SBuf&& S) : store_(std::move(S.store_)), off_(S.off_), len_(S.len_) {
++stats.moves;
- S.store_=NULL; //RefCount supports NULL, and S is about to be destructed
- S.off_=0;
- S.len_=0;
+ S.store_ = nullptr; //RefCount supports nullptr, and S is about to be destructed
+ S.off_ = S.len_ = 0;
}
-#endif
/** Constructor: import c-style string
*
friend class Locker;
MemBlob::Pointer store_; ///< memory block, possibly shared with other SBufs
- size_type off_; ///< our content start offset from the beginning of shared store_
- size_type len_; ///< number of our content bytes in shared store_
+ size_type off_ = 0; ///< our content start offset from the beginning of shared store_
+ size_type len_ = 0; ///< number of our content bytes in shared store_
static SBufStats stats; ///< class-wide statistics
/** obtain prototype store
#include <iostream>
-SBufStats::SBufStats()
- : alloc(0), allocCopy(0), allocFromCString(0),
- assignFast(0), clear(0), append(0), moves(0), toStream(0), setChar(0),
- getChar(0), compareSlow(0), compareFast(0), copyOut(0),
- rawAccess(0), nulTerminate(0), chop(0), trim(0), find(0),
- caseChange(0), cowFast(0), cowSlow(0), live(0)
-{}
-
SBufStats&
SBufStats::operator +=(const SBufStats& ss)
{
class SBufStats
{
public:
- uint64_t alloc; ///<number of calls to SBuf constructors
- uint64_t allocCopy; ///<number of calls to SBuf copy-constructor
- uint64_t allocFromCString; ///<number of copy-allocations from c-strings
- uint64_t assignFast; ///<number of no-copy assignment operations
- uint64_t clear; ///<number of clear operations
- uint64_t append; ///<number of append operations
- uint64_t moves; ///<number of move constructions/assignments
- uint64_t toStream; ///<number of write operations to ostreams
- uint64_t setChar; ///<number of calls to setAt
- uint64_t getChar; ///<number of calls to at() and operator[]
- uint64_t compareSlow; ///<number of comparison operations requiring data scan
- uint64_t compareFast; ///<number of comparison operations not requiring data scan
- uint64_t copyOut; ///<number of data-copies to other forms of buffers
- uint64_t rawAccess; ///<number of accesses to raw contents
- uint64_t nulTerminate; ///<number of c_str() terminations
- uint64_t chop; ///<number of chop operations
- uint64_t trim; ///<number of trim operations
- uint64_t find; ///<number of find operations
- uint64_t caseChange; ///<number of toUpper and toLower operations
- uint64_t cowFast; ///<number of cow operations not actually requiring a copy
- uint64_t cowSlow; ///<number of cow operations requiring a copy
- uint64_t live; ///<number of currently-allocated SBuf
-
///Dump statistics to an ostream.
std::ostream& dump(std::ostream &os) const;
- SBufStats();
SBufStats& operator +=(const SBufStats&);
+
+public:
+ uint64_t alloc = 0; ///<number of calls to SBuf constructors
+ uint64_t allocCopy = 0; ///<number of calls to SBuf copy-constructor
+ uint64_t allocFromCString = 0; ///<number of copy-allocations from c-strings
+ uint64_t assignFast = 0; ///<number of no-copy assignment operations
+ uint64_t clear = 0; ///<number of clear operations
+ uint64_t append = 0; ///<number of append operations
+ uint64_t moves = 0; ///<number of move constructions/assignments
+ uint64_t toStream = 0; ///<number of write operations to ostreams
+ uint64_t setChar = 0; ///<number of calls to setAt
+ uint64_t getChar = 0; ///<number of calls to at() and operator[]
+ uint64_t compareSlow = 0; ///<number of comparison operations requiring data scan
+ uint64_t compareFast = 0; ///<number of comparison operations not requiring data scan
+ uint64_t copyOut = 0; ///<number of data-copies to other forms of buffers
+ uint64_t rawAccess = 0; ///<number of accesses to raw contents
+ uint64_t nulTerminate = 0; ///<number of c_str() terminations
+ uint64_t chop = 0; ///<number of chop operations
+ uint64_t trim = 0; ///<number of trim operations
+ uint64_t find = 0; ///<number of find operations
+ uint64_t caseChange = 0; ///<number of toUpper and toLower operations
+ uint64_t cowFast = 0; ///<number of cow operations not actually requiring a copy
+ uint64_t cowSlow = 0; ///<number of cow operations requiring a copy
+ uint64_t live = 0; ///<number of currently-allocated SBuf
};
#endif /* SQUID_SBUF_STATS_H */
const SBuf::size_type SBuf::npos;
const SBuf::size_type SBuf::maxSize;
-SBufStats::SBufStats() {}
std::ostream& SBufStats::dump(std::ostream &os) const STUB_RETVAL(os)
SBufStats& SBufStats::operator +=(const SBufStats&) STUB_RETVAL(*this)