[wpiutil] Change StringExtras split() to template (#7636)

It now calls back a function for each part rather than creating a SmallVector.
This commit is contained in:
Peter Johnson
2025-01-05 20:53:43 -08:00
committed by GitHub
parent 0f6693594c
commit 03d9e96877
17 changed files with 161 additions and 171 deletions

View File

@@ -12,7 +12,6 @@
#include <imgui.h>
#include <imgui_stdlib.h>
#include <ntcore_cpp.h>
#include <wpi/SmallVector.h>
#include <wpi/StringExtras.h>
#include "glass/Context.h"
@@ -69,12 +68,10 @@ void NetworkTablesSettings::Thread::Main() {
(team = wpi::parse_integer<unsigned int>(serverTeam, 10))) {
nt::SetServerTeam(m_inst, team.value(), m_port);
} else {
wpi::SmallVector<std::string_view, 4> serverNames;
std::vector<std::pair<std::string_view, unsigned int>> servers;
wpi::split(serverTeam, serverNames, ',', -1, false);
for (auto&& serverName : serverNames) {
wpi::split(serverTeam, ',', -1, false, [&](auto serverName) {
servers.emplace_back(serverName, m_port);
}
});
nt::SetServer(m_inst, servers);
}