From 2c9ad834fe84628ef0b888413a8587587fe9888c Mon Sep 17 00:00:00 2001 From: Ryan Blue Date: Sun, 20 Oct 2024 22:57:10 -0400 Subject: [PATCH] Store pointer to group instead of string --- wpilibc/src/main/native/cpp/Alert.cpp | 10 ++++------ wpilibc/src/main/native/include/frc/Alert.h | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/wpilibc/src/main/native/cpp/Alert.cpp b/wpilibc/src/main/native/cpp/Alert.cpp index 6a16b8dd763..c9267ad03e0 100644 --- a/wpilibc/src/main/native/cpp/Alert.cpp +++ b/wpilibc/src/main/native/cpp/Alert.cpp @@ -35,7 +35,7 @@ Alert::Alert(std::string_view text, AlertType type) : Alert("Alerts", text, type) {} Alert::Alert(std::string_view group, std::string_view text, AlertType type) - : m_type(type), m_text(text), m_group{group} {} + : m_type(type), m_text(text), m_group{&GetGroupSendable(group)} {} Alert::~Alert() { Set(false); @@ -48,11 +48,9 @@ void Alert::Set(bool active) { if (active) { m_activeStartTime = frc::RobotController::GetFPGATime(); - GetGroupSendable(m_group).GetSetForType(m_type).emplace(m_activeStartTime, - m_text); + m_group->GetSetForType(m_type).emplace(m_activeStartTime, m_text); } else { - GetGroupSendable(m_group).GetSetForType(m_type).erase( - {m_activeStartTime, m_text}); + m_group->GetSetForType(m_type).erase({m_activeStartTime, m_text}); } m_active = active; } @@ -63,7 +61,7 @@ void Alert::SetText(std::string_view text) { } if (m_active) { - auto set = GetGroupSendable(m_group).GetSetForType(m_type); + auto set = m_group->GetSetForType(m_type); auto iter = set.find({m_activeStartTime, m_text}); auto hint = set.erase(iter); set.emplace_hint(hint, m_activeStartTime, m_text); diff --git a/wpilibc/src/main/native/include/frc/Alert.h b/wpilibc/src/main/native/include/frc/Alert.h index 2e0f92fa66c..4d43edd5e58 100644 --- a/wpilibc/src/main/native/include/frc/Alert.h +++ b/wpilibc/src/main/native/include/frc/Alert.h @@ -139,7 +139,7 @@ class Alert { AlertType m_type; std::string m_text; - std::string m_group; + SendableAlerts* m_group; bool m_active = false; uint64_t m_activeStartTime;