From ad393b83a20ca4efdfd5f068d3297034c4c10244 Mon Sep 17 00:00:00 2001 From: Gabi Melman Date: Wed, 20 May 2020 22:39:25 +0300 Subject: [PATCH] Revert 01dac453db3343cdf537d5c7db28ecc61a067061 --- include/spdlog/sinks/ringbuffer_sink.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/include/spdlog/sinks/ringbuffer_sink.h b/include/spdlog/sinks/ringbuffer_sink.h index 1ee3f691..16f7cb56 100644 --- a/include/spdlog/sinks/ringbuffer_sink.h +++ b/include/spdlog/sinks/ringbuffer_sink.h @@ -28,11 +28,10 @@ public: std::vector last_raw(size_t lim = 0) { std::lock_guard lock(base_sink::mutex_); - auto items_available = q_.size(); - auto n_items = lim > 0 ? (std::min)(lim, items_available) : items_available; + auto n_items = lim > 0 ? (std::min)(lim, q_.size()) : q_.size(); std::vector ret; ret.reserve(n_items); - for (size_t i = (items_available - n_items); i < items_available; i++) + for (size_t i = 0; i < n_items; i++) { ret.push_back(q_.at(i)); } @@ -42,11 +41,10 @@ public: std::vector last_formatted(size_t lim = 0) { std::lock_guard lock(base_sink::mutex_); - auto items_available = q_.size(); - auto n_items = lim > 0 ? (std::min)(lim, items_available) : items_available; + auto n_items = lim > 0 ? (std::min)(lim, q_.size()) : q_.size(); std::vector ret; ret.reserve(n_items); - for (size_t i = (items_available - n_items); i < items_available; i++) + for (size_t i = 0; i < n_items; i++) { memory_buf_t formatted; base_sink::formatter_->format(q_.at(i), formatted);