Skip to content

Commit

Permalink
lib/fmt/ToSpan: un-inline VFmtTruncate()
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxKellermann committed Sep 2, 2024
1 parent eaecca4 commit 7a8f36c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
13 changes: 13 additions & 0 deletions src/lib/fmt/ToSpan.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// SPDX-License-Identifier: BSD-2-Clause
// author: Max Kellermann <[email protected]>

#include "ToSpan.hxx"

std::string_view
VFmtTruncate(std::span<char> buffer,
fmt::string_view format_str, fmt::format_args args) noexcept
{
auto [p, _] = fmt::vformat_to_n(buffer.begin(), buffer.size(),
format_str, args);
return {buffer.begin(), p};
}
9 changes: 2 additions & 7 deletions src/lib/fmt/ToSpan.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,9 @@
#include <string_view>

[[nodiscard]] [[gnu::pure]]
inline std::string_view
std::string_view
VFmtTruncate(std::span<char> buffer,
fmt::string_view format_str, fmt::format_args args) noexcept
{
auto [p, _] = fmt::vformat_to_n(buffer.begin(), buffer.size(),
format_str, args);
return {buffer.begin(), p};
}
fmt::string_view format_str, fmt::format_args args) noexcept;

template<typename S, typename... Args>
[[nodiscard]] [[gnu::pure]]
Expand Down
1 change: 1 addition & 0 deletions src/lib/fmt/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ endif
fmt = static_library(
'fmt',
'RuntimeError.cxx',
'ToSpan.cxx',
include_directories: inc,
dependencies: libfmt,
)
Expand Down

0 comments on commit 7a8f36c

Please sign in to comment.