mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +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:
@@ -5,6 +5,7 @@
|
||||
#include "glass/hardware/AnalogInput.h"
|
||||
|
||||
#include <imgui.h>
|
||||
#include <wpi/StringExtras.h>
|
||||
|
||||
#include "glass/Context.h"
|
||||
#include "glass/DataSource.h"
|
||||
@@ -22,9 +23,9 @@ void glass::DisplayAnalogInput(AnalogInputModel* model, int index) {
|
||||
std::string& name = GetStorage().GetString("name");
|
||||
char label[128];
|
||||
if (!name.empty()) {
|
||||
std::snprintf(label, sizeof(label), "%s [%d]###name", name.c_str(), index);
|
||||
wpi::format_to_n_c_str(label, sizeof(label), "{} [{}]###name", name, index);
|
||||
} else {
|
||||
std::snprintf(label, sizeof(label), "In[%d]###name", index);
|
||||
wpi::format_to_n_c_str(label, sizeof(label), "In[{}]###name", index);
|
||||
}
|
||||
|
||||
if (model->IsGyro()) {
|
||||
|
||||
Reference in New Issue
Block a user