From 2ffc7c2088613f6b5dfed252d02307f7e00ca2c4 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 6 Mar 2023 16:25:52 +0100 Subject: [PATCH] io/BufferedOutputStream: remove unused method Format() --- src/io/BufferedOutputStream.cxx | 43 --------------------------------- src/io/BufferedOutputStream.hxx | 7 ------ 2 files changed, 50 deletions(-) diff --git a/src/io/BufferedOutputStream.cxx b/src/io/BufferedOutputStream.cxx index 90ee0ba6e..f63ed7f0b 100644 --- a/src/io/BufferedOutputStream.cxx +++ b/src/io/BufferedOutputStream.cxx @@ -9,7 +9,6 @@ #include #include -#include #ifdef _UNICODE #include "system/Error.hxx" @@ -52,48 +51,6 @@ BufferedOutputStream::Write(const char *p) Write(p, strlen(p)); } -void -BufferedOutputStream::Format(const char *fmt, ...) -{ - auto r = buffer.Write(); - if (r.empty()) { - Flush(); - r = buffer.Write(); - } - - /* format into the buffer */ - std::va_list ap; - va_start(ap, fmt); - std::size_t size = vsnprintf((char *)r.data(), r.size(), fmt, ap); - va_end(ap); - - if (size >= r.size()) [[unlikely]] { - /* buffer was not large enough; flush it and try - again */ - - Flush(); - - r = buffer.Write(); - - if (size >= r.size()) [[unlikely]] { - /* still not enough space: grow the buffer and - try again */ - ++size; - r = {buffer.Write(size), size}; - } - - /* format into the new buffer */ - va_start(ap, fmt); - size = vsnprintf((char *)r.data(), r.size(), fmt, ap); - va_end(ap); - - /* this time, it must fit */ - assert(size < r.size()); - } - - buffer.Append(size); -} - void BufferedOutputStream::VFmt(fmt::string_view format_str, fmt::format_args args) { diff --git a/src/io/BufferedOutputStream.hxx b/src/io/BufferedOutputStream.hxx index 7f392d80f..5395fc452 100644 --- a/src/io/BufferedOutputStream.hxx +++ b/src/io/BufferedOutputStream.hxx @@ -4,7 +4,6 @@ #ifndef BUFFERED_OUTPUT_STREAM_HXX #define BUFFERED_OUTPUT_STREAM_HXX -#include "util/Compiler.h" #include "util/DynamicFifoBuffer.hxx" #include @@ -65,12 +64,6 @@ public: */ void Write(const char *p); - /** - * Write a printf-style formatted string. - */ - gcc_printf(2,3) - void Format(const char *fmt, ...); - void VFmt(fmt::string_view format_str, fmt::format_args args); template