mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
Replace std::snprintf() with wpi::format_to_n_c_str() (#5645)
fmtlib uses consteval format string processing, which makes it more efficient than std::snprintf(). snprintf()s in libuv, mpack, processstarter, and wpigui were left alone. processstarter uses stdlib only, and wpigui only depends on imgui. fmt::format_to_n() is analogous to std::format_to_n() (https://en.cppreference.com/w/cpp/utility/format/format_to_n) wpi::format_to_n_c_str() is a wrapper which adds the trailing NUL.
This commit is contained in:
@@ -56,9 +56,12 @@ void Window::Display() {
|
||||
}
|
||||
|
||||
char label[128];
|
||||
std::snprintf(label, sizeof(label), "%s###%s",
|
||||
m_name.empty() ? m_defaultName.c_str() : m_name.c_str(),
|
||||
m_id.c_str());
|
||||
if (m_name.empty()) {
|
||||
wpi::format_to_n_c_str(label, sizeof(label), "{}###{}", m_defaultName,
|
||||
m_id);
|
||||
} else {
|
||||
wpi::format_to_n_c_str(label, sizeof(label), "{}###{}", m_name, m_id);
|
||||
}
|
||||
|
||||
if (Begin(label, &m_visible, m_flags)) {
|
||||
if (m_renamePopupEnabled || m_view->HasSettings()) {
|
||||
|
||||
Reference in New Issue
Block a user