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:
@@ -4,6 +4,8 @@
|
||||
|
||||
#include "glass/hardware/AnalogGyro.h"
|
||||
|
||||
#include <wpi/StringExtras.h>
|
||||
|
||||
#include "glass/DataSource.h"
|
||||
#include "glass/other/DeviceTree.h"
|
||||
|
||||
@@ -11,7 +13,8 @@ using namespace glass;
|
||||
|
||||
void glass::DisplayAnalogGyroDevice(AnalogGyroModel* model, int index) {
|
||||
char name[32];
|
||||
std::snprintf(name, sizeof(name), "AnalogGyro[%d]", index);
|
||||
wpi::format_to_n_c_str(name, sizeof(name), "AnalogGyro[{}]", index);
|
||||
|
||||
if (BeginDevice(name)) {
|
||||
// angle
|
||||
if (auto angleData = model->GetAngleData()) {
|
||||
|
||||
Reference in New Issue
Block a user