Skip to content

Commit

Permalink
Remove unneeded FormatBuffre::append() overloads
Browse files Browse the repository at this point in the history
After benchmarking it turned out it does not affect performance.

Signed-off-by: Pavel Artsishevsky <polter.rnd@gmail.com>
  • Loading branch information
polter-rnd committed Nov 27, 2024
1 parent bdc3397 commit faad40c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 30 deletions.
29 changes: 0 additions & 29 deletions include/slimlog/format.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,35 +207,6 @@ class FormatBuffer final : public Util::MemoryBuffer<Char, BufferSize, Allocator
public:
using Util::MemoryBuffer<Char, BufferSize, Allocator>::MemoryBuffer;

/**
* @brief Appends data to the end of the buffer.
*
* @tparam ContiguousRange Type of the source object.
*
* @param range Source object containing data to be added to the buffer.
*/
template<typename ContiguousRange>
void append(const ContiguousRange& range) // cppcheck-suppress duplInheritedMember
{
append(range.data(), std::next(range.data(), range.size()));
}

/**
* @brief Appends data to the end of the buffer.
*
* @tparam U Input data type.
* @param begin Begin input iterator.
* @param end End input iterator.
*/
template<typename U>
void append(const U* begin, const U* end) // cppcheck-suppress duplInheritedMember
{
const auto buf_size = this->size();
const auto count = Util::Types::to_unsigned(end - begin);
this->resize(buf_size + count);
std::uninitialized_copy_n(begin, count, std::next(this->begin(), buf_size));
}

/**
* @brief Formats a log message with compile-time argument checks.
*
Expand Down
4 changes: 3 additions & 1 deletion include/slimlog/util/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,8 @@ class MemoryBuffer : public Buffer<T> {
using const_reference = const T&; // NOLINT(readability-identifier-naming)
/// @endcond

using Buffer<T>::append;

/**
* @brief Constructs a new MemoryBuffer object.
*
Expand Down Expand Up @@ -434,7 +436,7 @@ class MemoryBuffer : public Buffer<T> {
template<typename ContiguousRange>
void append(const ContiguousRange& range)
{
Buffer<T>::append(range.data(), range.data() + range.size());
Buffer<T>::append(range.data(), std::next(range.data(), range.size()));
}

protected:
Expand Down

0 comments on commit faad40c

Please sign in to comment.