From 1e62a038f13cc2e47d6f17fde1e8b8f94e6cf307 Mon Sep 17 00:00:00 2001 From: Gregg Date: Sun, 12 Nov 2023 12:33:09 -0600 Subject: [PATCH] Changed unordered_set to vector when checking for duplicate AID This eliminated the use of unordered_set everywhere in HomeSpan --- src/HomeSpan.cpp | 6 +++--- src/HomeSpan.h | 2 -- src/Network.h | 3 --- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/HomeSpan.cpp b/src/HomeSpan.cpp index 2de8c34..78929dd 100644 --- a/src/HomeSpan.cpp +++ b/src/HomeSpan.cpp @@ -865,7 +865,7 @@ void Span::processSerialCommand(const char *c){ int nErrors=0; int nWarnings=0; - unordered_set aidValues; + vector aidValues; char pNames[][7]={"PR","PW","EV","AA","TW","HD","WR"}; for(auto acc=Accessories.begin(); acc!=Accessories.end(); acc++){ @@ -875,10 +875,10 @@ void Span::processSerialCommand(const char *c){ if(acc==Accessories.begin() && (*acc)->aid!=1) LOG0(" *** ERROR #%d! AID of first Accessory must always be 1 ***\n",++nErrors); - if(aidValues.find((*acc)->aid)!=aidValues.end()) + if(std::find(aidValues.begin(),aidValues.end(),(*acc)->aid)!=aidValues.end()) LOG0(" *** ERROR #%d! AID already in use for another Accessory ***\n",++nErrors); - aidValues.insert((*acc)->aid); + aidValues.push_back((*acc)->aid); for(auto svc=(*acc)->Services.begin(); svc!=(*acc)->Services.end(); svc++){ LOG0(" \u279f Service %s: IID=%d, %sUUID=\"%s\"\n",(*svc)->hapName,(*svc)->iid,(*svc)->isCustom?"Custom-":"",(*svc)->type); diff --git a/src/HomeSpan.h b/src/HomeSpan.h index a61b5ca..00636d0 100644 --- a/src/HomeSpan.h +++ b/src/HomeSpan.h @@ -37,7 +37,6 @@ #include #include #include -#include #include #include #include @@ -55,7 +54,6 @@ using std::vector; using std::unordered_map; -using std::unordered_set; using std::list; enum { diff --git a/src/Network.h b/src/Network.h index 679ecfe..1cb17d4 100644 --- a/src/Network.h +++ b/src/Network.h @@ -28,11 +28,8 @@ #pragma once #include -#include #include "Settings.h" -using std::unordered_set; - const int MAX_SSID=32; // max number of characters in WiFi SSID const int MAX_PWD=64; // max number of characters in WiFi Password