use <fmt/core.h> instead of <fmt/format.h>

Should lighten compile times.

The only loss here is we'll no longer inherit e.g. "float" format specifiers for qvec3f.
This commit is contained in:
Eric Wasylishen 2022-09-28 21:50:04 -06:00
parent 1160352a24
commit 1726f95484
9 changed files with 21 additions and 16 deletions

View File

@ -25,7 +25,7 @@
#include <cstdint> #include <cstdint>
#include <limits.h> #include <limits.h>
#include <fmt/format.h> #include <fmt/core.h>
#include <atomic> #include <atomic>
#include <mutex> #include <mutex>

View File

@ -35,7 +35,7 @@
#include <utility> #include <utility>
#include <tuple> #include <tuple>
#include <fmt/format.h> #include <fmt/core.h>
#include <fmt/ostream.h> #include <fmt/ostream.h>
#include "tbb/parallel_for.h" #include "tbb/parallel_for.h"

View File

@ -20,7 +20,7 @@
#include <common/qvec.hh> #include <common/qvec.hh>
#include <cmath> // for NAN #include <cmath> // for NAN
#include <fmt/format.h> #include <fmt/core.h>
/* /*
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)

View File

@ -19,7 +19,7 @@
#pragma once #pragma once
#include <fmt/format.h> #include <fmt/core.h>
#include <cinttypes> #include <cinttypes>
#include <array> #include <array>
@ -271,7 +271,9 @@ enum class plane_type_t
}; };
// Fmt support // Fmt support
template <> struct fmt::formatter<plane_type_t> : formatter<string_view> { template <> struct fmt::formatter<plane_type_t> {
constexpr auto parse(format_parse_context &ctx) -> decltype(ctx.begin()) { return ctx.end(); }
template <typename FormatContext> template <typename FormatContext>
auto format(plane_type_t t, FormatContext& ctx) { auto format(plane_type_t t, FormatContext& ctx) {
string_view name = "unknown"; string_view name = "unknown";
@ -284,7 +286,7 @@ template <> struct fmt::formatter<plane_type_t> : formatter<string_view> {
case plane_type_t::PLANE_ANYY: name = "PLANE_ANYY"; break; case plane_type_t::PLANE_ANYY: name = "PLANE_ANYY"; break;
case plane_type_t::PLANE_ANYZ: name = "PLANE_ANYZ"; break; case plane_type_t::PLANE_ANYZ: name = "PLANE_ANYZ"; break;
} }
return formatter<string_view>::format(name, ctx); return format_to(ctx.out(), "{}", name);
} }
}; };

View File

@ -131,15 +131,17 @@ inline fs::path DefaultExtension(const fs::path &path, const fs::path &extension
return fs::path(path).replace_extension(extension); return fs::path(path).replace_extension(extension);
} }
#include <fmt/format.h> #include <fmt/core.h>
// TODO: no wchar_t support in this version apparently // TODO: no wchar_t support in this version apparently
template<> template<>
struct fmt::formatter<fs::path> : formatter<std::string> struct fmt::formatter<fs::path>
{ {
constexpr auto parse(format_parse_context &ctx) -> decltype(ctx.begin()) { return ctx.end(); }
template<typename FormatContext> template<typename FormatContext>
auto format(const fs::path &p, FormatContext &ctx) auto format(const fs::path &p, FormatContext &ctx)
{ {
return formatter<std::string>::format(p.string(), ctx); return format_to(ctx.out(), "{}", p.string());
} }
}; };

View File

@ -30,7 +30,7 @@
#include <cstdarg> #include <cstdarg>
#include <filesystem> #include <filesystem>
#include <list> #include <list>
#include <fmt/format.h> #include <fmt/core.h>
#include <common/bitflags.hh> #include <common/bitflags.hh>
#include <common/fs.hh> #include <common/fs.hh>

View File

@ -26,7 +26,7 @@
#include <algorithm> #include <algorithm>
#include <array> #include <array>
#include <ostream> #include <ostream>
#include <fmt/format.h> #include <fmt/core.h>
#include <tuple> #include <tuple>
#include "common/mathlib.hh" #include "common/mathlib.hh"
#include "common/cmdlib.hh" #include "common/cmdlib.hh"
@ -340,17 +340,19 @@ public:
// Fmt support // Fmt support
template<class T, size_t N> template<class T, size_t N>
struct fmt::formatter<qvec<T, N>> : formatter<T> struct fmt::formatter<qvec<T, N>>
{ {
constexpr auto parse(format_parse_context &ctx) -> decltype(ctx.begin()) { return ctx.end(); }
template<typename FormatContext> template<typename FormatContext>
auto format(const qvec<T, N> &p, FormatContext &ctx) -> decltype(ctx.out()) auto format(const qvec<T, N> &p, FormatContext &ctx) -> decltype(ctx.out())
{ {
for (size_t i = 0; i < N - 1; i++) { for (size_t i = 0; i < N - 1; i++) {
formatter<T>::format(p[i], ctx); format_to(ctx.out(), "{}", p[i]);
format_to(ctx.out(), " "); format_to(ctx.out(), " ");
} }
return formatter<T>::format(p[N - 1], ctx); return format_to(ctx.out(), "{}", p[N - 1]);
} }
}; };

View File

@ -26,7 +26,7 @@ See file, 'COPYING', for details.
#include <QWheelEvent> #include <QWheelEvent>
#include <QKeyEvent> #include <QKeyEvent>
#include <QTime> #include <QTime>
#include <fmt/format.h> #include <fmt/core.h>
GLView::GLView(QWidget *parent) GLView::GLView(QWidget *parent)
: QOpenGLWidget(parent), m_keysPressed(0), m_keymoveUpdateTimer(0), m_lastMouseDownPos(0, 0), m_displayAspect(1), : QOpenGLWidget(parent), m_keysPressed(0), m_keymoveUpdateTimer(0), m_lastMouseDownPos(0, 0), m_displayAspect(1),

View File

@ -5,7 +5,6 @@
#include <random> #include <random>
#include <algorithm> // for std::sort #include <algorithm> // for std::sort
#include <fmt/format.h>
#include <common/qvec.hh> #include <common/qvec.hh>