[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

@@ -10,7 +10,6 @@
#include <utility>
#include <vector>
#include <wpi/SmallVector.h>
#include <wpi/StringExtras.h>
#include <wpi/fs.h>
#include <wpi/print.h>
@@ -100,7 +99,6 @@ int HAL_LoadOneExtension(const char* library) {
int HAL_LoadExtensions(void) {
int rc = 1;
wpi::SmallVector<std::string_view, 2> libraries;
const char* e = std::getenv("HALSIM_EXTENSIONS");
if (!e) {
if (GetShowNotFoundMessage()) {
@@ -109,13 +107,11 @@ int HAL_LoadExtensions(void) {
}
return rc;
}
wpi::split(e, libraries, DELIM, -1, false);
for (auto& library : libraries) {
rc = HAL_LoadOneExtension(std::string(library).c_str());
if (rc < 0) {
break;
wpi::split(e, DELIM, -1, false, [&](auto library) {
if (rc >= 0) {
rc = HAL_LoadOneExtension(std::string(library).c_str());
}
}
});
return rc;
}