io/BufferedOutputStream: remove unused method Format()

This commit is contained in:
Max Kellermann 2023-03-06 16:25:52 +01:00
parent 1f56960c44
commit 2ffc7c2088
2 changed files with 0 additions and 50 deletions

View File

@ -9,7 +9,6 @@
#include <cstdarg>
#include <string.h>
#include <stdio.h>
#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)
{

View File

@ -4,7 +4,6 @@
#ifndef BUFFERED_OUTPUT_STREAM_HXX
#define BUFFERED_OUTPUT_STREAM_HXX
#include "util/Compiler.h"
#include "util/DynamicFifoBuffer.hxx"
#include <fmt/core.h>
@ -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<typename S, typename... Args>