Make inline_buffer_size public and update docs

This commit is contained in:
Victor Zverovich
2018-03-04 10:33:42 -08:00
parent 995b63adfe
commit f1ede6380b
6 changed files with 20 additions and 20 deletions

View File

@@ -166,7 +166,7 @@ int safe_strerror(
void format_error_code(internal::buffer &out, int error_code,
string_view message) FMT_NOEXCEPT {
// Report error code making sure that the output fits into
// INLINE_BUFFER_SIZE to avoid dynamic memory allocation and potential
// inline_buffer_size to avoid dynamic memory allocation and potential
// bad_alloc.
out.resize(0);
static const char SEP[] = ": ";
@@ -181,13 +181,13 @@ void format_error_code(internal::buffer &out, int error_code,
}
error_code_size += internal::count_digits(abs_value);
writer w(out);
if (message.size() <= internal::INLINE_BUFFER_SIZE - error_code_size) {
if (message.size() <= inline_buffer_size - error_code_size) {
w.write(message);
w.write(SEP);
}
w.write(ERROR_STR);
w.write(error_code);
assert(out.size() <= internal::INLINE_BUFFER_SIZE);
assert(out.size() <= inline_buffer_size);
}
void report_error(FormatFunc func, int error_code,
@@ -332,7 +332,7 @@ FMT_FUNC void internal::format_windows_error(
internal::buffer &out, int error_code, string_view message) FMT_NOEXCEPT {
FMT_TRY {
wmemory_buffer buf;
buf.resize(INLINE_BUFFER_SIZE);
buf.resize(inline_buffer_size);
for (;;) {
wchar_t *system_message = &buf[0];
int result = FormatMessageW(
@@ -364,7 +364,7 @@ FMT_FUNC void format_system_error(
internal::buffer &out, int error_code, string_view message) FMT_NOEXCEPT {
FMT_TRY {
memory_buffer buf;
buf.resize(internal::INLINE_BUFFER_SIZE);
buf.resize(inline_buffer_size);
for (;;) {
char *system_message = &buf[0];
int result = safe_strerror(error_code, system_message, buf.size());

View File

@@ -335,10 +335,6 @@ FMT_CONSTEXPR typename std::make_unsigned<Int>::type to_unsigned(Int value) {
return static_cast<typename std::make_unsigned<Int>::type>(value);
}
// The number of characters to store in the basic_memory_buffer object itself
// to avoid dynamic memory allocation.
enum { INLINE_BUFFER_SIZE = 500 };
#if FMT_SECURE_SCL
// Use checked iterator to avoid warnings on MSVC.
template <typename T>
@@ -371,6 +367,10 @@ class locale_provider {
virtual fmt::locale locale();
};
// The number of characters to store in the basic_memory_buffer object itself
// to avoid dynamic memory allocation.
enum { inline_buffer_size = 500 };
/**
\rst
A dynamically growing memory buffer for trivially copyable/constructible types
@@ -400,7 +400,7 @@ class locale_provider {
The output can be converted to an ``std::string`` with ``to_string(out)``.
\endrst
*/
template <typename T, std::size_t SIZE = internal::INLINE_BUFFER_SIZE,
template <typename T, std::size_t SIZE = inline_buffer_size,
typename Allocator = std::allocator<T> >
class basic_memory_buffer: private Allocator, public internal::basic_buffer<T> {
private: