var names and some minor cleanups

This commit is contained in:
gabime
2014-03-22 16:26:08 +02:00
parent 8494590fb3
commit a287bccd40
5 changed files with 23 additions and 47 deletions

View File

@@ -5,14 +5,11 @@
#include <cstring>
#include <vector>
// Fast buffer
// Fast memory storage
// stores its contents on the stack when possible, in vector<char> otherwise
// NOTE: User should be remember that returned buffer might be on the stack!!
namespace c11log
{
namespace details
{
namespace c11log { namespace details {
template<std::size_t STACK_SIZE=128>
class fast_buf

View File

@@ -1,7 +1,7 @@
#pragma once
// Faster than ostringstream--returns its string by ref
#include <ostream>
#include "c11log/details/fast_buf.h"
namespace c11log
@@ -19,21 +19,14 @@ public:
str_devicebuf(str_devicebuf&& other) = delete;
str_devicebuf& operator=(const str_devicebuf&) = delete;
str_devicebuf& operator=(str_devicebuf&&) = delete;
/*
const std::string& str_ref() const
{
return _str;
}
*/
bufpair_t buf()
{
return _fastbuf.get();
}
void reset_str()
{
//_str.clear();
{
_fastbuf.clear();
}
@@ -46,21 +39,13 @@ protected:
// copy the give buffer into the accumulated string.
// reserve initially 128 bytes which should be enough for common log lines
std::streamsize xsputn(const char_type* s, std::streamsize count) override
{
/*
if(_str.capacity() < k_initial_reserve)
{
_str.reserve(k_initial_reserve);
}
_str.append(s, static_cast<unsigned int>(count));
*/
{
_fastbuf.append(s, static_cast<unsigned int>(count));
return count;
}
int_type overflow(int_type ch) override
{
bool not_eofile = traits_type::not_eof(ch);
if (not_eofile)
{
@@ -70,7 +55,6 @@ protected:
return not_eofile;
}
private:
//std::string _str;
fast_buf<192> _fastbuf;
};
@@ -83,12 +67,7 @@ public:
fast_oss(const fast_oss& other) = delete;
fast_oss(fast_oss&& other) = delete;
fast_oss& operator=(const fast_oss& other) = delete;
/*
const std::string& str_ref() const
{
return _dev.str_ref();
}
*/
bufpair_t buf()
{
return _dev.buf();

View File

@@ -38,12 +38,13 @@ public:
line_logger& operator=(const line_logger&) = delete;
line_logger& operator=(line_logger&&) = delete;
// The move ctor should only be called on start of logging line,
// where no logging happened yet for this line so no need to copy the string from the other
line_logger(line_logger&& other) :
_callback_logger(other._callback_logger),
// The move ctor should only be called on start of logging line,
// where no logging happened yet for this line so no need to copy the string from the other
_callback_logger(other._callback_logger),
_oss(),
_level(other._level) {};
_level(other._level),
_enabled(other._enabled) {}
~line_logger()