mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[wpiutil] Replace LLVM StringMap impl with std::map
As string_view operations on std::map<std::string> won't be integrated until C++26, placeholder implementations are used which are less efficient in a couple of situations (e.g. insert with hint).
This commit is contained in:
@@ -90,8 +90,8 @@ static void CopyRawData(wpi::StringMap<MotorData>* dataset) {
|
||||
auto& data = *dataset;
|
||||
// Loads the Raw Data
|
||||
for (auto& it : data) {
|
||||
auto key = it.first();
|
||||
auto& motorData = it.getValue();
|
||||
auto& key = it.first;
|
||||
auto& motorData = it.second;
|
||||
|
||||
if (!wpi::contains(key, "raw")) {
|
||||
data[fmt::format("raw-{}", key)] = motorData;
|
||||
@@ -126,7 +126,7 @@ void AnalysisManager::PrepareGeneralData() {
|
||||
WPI_INFO(m_logger, "{}", "Converting raw data to PreparedData struct.");
|
||||
// Convert data to PreparedData structs
|
||||
for (auto& it : m_data.motorData) {
|
||||
auto key = it.first();
|
||||
auto key = it.first;
|
||||
preparedData[key] = ConvertToPrepared(m_data.motorData[key]);
|
||||
WPI_INFO(m_logger, "SAMPLES {}", preparedData[key].size());
|
||||
}
|
||||
|
||||
@@ -322,8 +322,8 @@ static units::second_t GetMaxStepTime(
|
||||
wpi::StringMap<std::vector<PreparedData>>& data) {
|
||||
auto maxStepTime = 0_s;
|
||||
for (auto& it : data) {
|
||||
auto key = it.first();
|
||||
auto& dataset = it.getValue();
|
||||
auto& key = it.first;
|
||||
auto& dataset = it.second;
|
||||
|
||||
if (IsRaw(key) && wpi::contains(key, "dynamic")) {
|
||||
if (!dataset.empty()) {
|
||||
@@ -351,8 +351,8 @@ void sysid::InitialTrimAndFilter(
|
||||
// Calculate Velocity Threshold if it hasn't been set yet
|
||||
if (settings->velocityThreshold == std::numeric_limits<double>::infinity()) {
|
||||
for (auto& it : preparedData) {
|
||||
auto key = it.first();
|
||||
auto& dataset = it.getValue();
|
||||
auto& key = it.first;
|
||||
auto& dataset = it.second;
|
||||
if (wpi::contains(key, "quasistatic")) {
|
||||
settings->velocityThreshold =
|
||||
std::min(settings->velocityThreshold,
|
||||
@@ -363,8 +363,8 @@ void sysid::InitialTrimAndFilter(
|
||||
}
|
||||
|
||||
for (auto& it : preparedData) {
|
||||
auto key = it.first();
|
||||
auto& dataset = it.getValue();
|
||||
auto& key = it.first;
|
||||
auto& dataset = it.second;
|
||||
|
||||
// Trim quasistatic test data to remove all points where voltage is zero or
|
||||
// velocity < velocity threshold.
|
||||
@@ -424,7 +424,7 @@ void sysid::AccelFilter(wpi::StringMap<std::vector<PreparedData>>* data) {
|
||||
|
||||
// Remove points with acceleration = 0
|
||||
for (auto& it : preparedData) {
|
||||
auto& dataset = it.getValue();
|
||||
auto& dataset = it.second;
|
||||
|
||||
for (size_t i = 0; i < dataset.size(); i++) {
|
||||
if (dataset.at(i).acceleration == 0.0) {
|
||||
@@ -436,7 +436,7 @@ void sysid::AccelFilter(wpi::StringMap<std::vector<PreparedData>>* data) {
|
||||
|
||||
// Confirm there's still data
|
||||
if (std::any_of(preparedData.begin(), preparedData.end(),
|
||||
[](const auto& it) { return it.getValue().empty(); })) {
|
||||
[](const auto& it) { return it.second.empty(); })) {
|
||||
throw sysid::InvalidDataError(
|
||||
"Acceleration filtering has removed all data.");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user