mirror of
https://github.com/fmtlib/fmt.git
synced 2024-12-25 15:21:54 +00:00
Optimize buffer construction
This commit is contained in:
parent
8cbfb6e727
commit
c8a8464f7d
@ -365,6 +365,9 @@ class basic_buffer {
|
|||||||
std::size_t capacity_;
|
std::size_t capacity_;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
// Don't initialize ptr_ since it is not accessed to save a few cycles.
|
||||||
|
basic_buffer(std::size_t sz) FMT_NOEXCEPT: size_(sz), capacity_(sz) {}
|
||||||
|
|
||||||
basic_buffer(T *p = FMT_NULL, std::size_t sz = 0, std::size_t cap = 0)
|
basic_buffer(T *p = FMT_NULL, std::size_t sz = 0, std::size_t cap = 0)
|
||||||
FMT_NOEXCEPT: ptr_(p), size_(sz), capacity_(cap) {}
|
FMT_NOEXCEPT: ptr_(p), size_(sz), capacity_(cap) {}
|
||||||
|
|
||||||
@ -445,8 +448,7 @@ class container_buffer : public basic_buffer<typename Container::value_type> {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit container_buffer(Container &c)
|
explicit container_buffer(Container &c)
|
||||||
: basic_buffer<typename Container::value_type>(&c[0], c.size(), c.size()),
|
: basic_buffer<typename Container::value_type>(c.size()), container_(c) {}
|
||||||
container_(c) {}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct error_handler {
|
struct error_handler {
|
||||||
|
Loading…
Reference in New Issue
Block a user