Skip to content

Commit 174f259

Browse files
committed
simplification workaround homebrew
1 parent e0343f4 commit 174f259

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

libmamba/src/core/logging.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -129,21 +129,18 @@ namespace mamba::logging
129129
constinit std::atomic<bool> message_logger_use_buffer;
130130

131131
// NOTE: this looks complicated because it's a workaround `std::vector` implementations
132-
// which are not `constexpr` (required by c++20), we defer the vector creation to the moment it's needed.
133-
// Constexpr constructor is required for a type which is usable in a `constinit` declaration,
134-
// which is required to avoid the static-initialization-fiasco (at least for initialization).
132+
// which are not `constexpr` (required by c++20), we defer the vector creation to the moment
133+
// it's needed. Constexpr constructor is required for a type which is usable in a
134+
// `constinit` declaration, which is required to avoid the static-initialization-fiasco (at
135+
// least for initialization).
136+
// TODO: once homebrew stl impl has `constexpr` vector, replace al lthis by just `using
137+
// MessageLoggerBuffer = vector<LogRecord>;`
135138
struct MessageLoggerBuffer
136139
{
137140
using buffer = std::vector<LogRecord>;
138141

139142
constexpr MessageLoggerBuffer() = default;
140143

141-
template<class T>
142-
auto push_back(T&& record)
143-
{
144-
return ready_records().push_back(std::forward<T>(record));
145-
}
146-
147144
auto ready_records() -> buffer&
148145
{
149146
if (not records)
@@ -155,6 +152,7 @@ namespace mamba::logging
155152

156153
std::optional<buffer> records;
157154
};
155+
158156
constinit util::synchronized_value<MessageLoggerBuffer> message_logger_buffer;
159157

160158
auto
@@ -191,7 +189,7 @@ namespace mamba::logging
191189
}
192190
else
193191
{
194-
message_logger_buffer->push_back(std::move(log_record));
192+
message_logger_buffer->ready_records().push_back(std::move(log_record));
195193
}
196194
}
197195

0 commit comments

Comments
 (0)