mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[ntcore] Cache GetEntry(name) values (#4531)
These are typically cached at higher levels anyway, but cache at lowest C++ layer as well for consistency with NT3.
This commit is contained in:
@@ -83,6 +83,7 @@ struct TopicData {
|
||||
unsigned int flags{0}; // for NT3 APIs
|
||||
std::string propertiesStr{"{}"}; // cached string for GetTopicInfo() et al
|
||||
wpi::json properties = wpi::json::object();
|
||||
NT_Entry entry{0}; // cached entry for GetEntry()
|
||||
|
||||
bool onNetwork{false}; // true if there are any remote publishers
|
||||
|
||||
@@ -2331,11 +2332,15 @@ NT_Entry LocalStorage::GetEntry(std::string_view name) {
|
||||
// Get the topic data
|
||||
auto* topic = m_impl->GetOrCreateTopic(name);
|
||||
|
||||
// Create subscriber
|
||||
auto* subscriber = m_impl->AddLocalSubscriber(topic, {});
|
||||
if (topic->entry == 0) {
|
||||
// Create subscriber
|
||||
auto* subscriber = m_impl->AddLocalSubscriber(topic, {});
|
||||
|
||||
// Create entry
|
||||
return m_impl->AddEntry(subscriber)->handle;
|
||||
// Create entry
|
||||
topic->entry = m_impl->AddEntry(subscriber)->handle;
|
||||
}
|
||||
|
||||
return topic->entry;
|
||||
}
|
||||
|
||||
std::string LocalStorage::GetEntryName(NT_Handle subentryHandle) {
|
||||
|
||||
Reference in New Issue
Block a user