Further improvements on Accesspoints class

Only go through the whole list again if needed
This commit is contained in:
Stefan Kremser
2018-03-29 16:40:23 +02:00
parent 36bd59f5cd
commit 7bd14a6bda
2 changed files with 9 additions and 10 deletions

View File

@@ -14,10 +14,10 @@ void Accesspoints::sort() {
int c = listSize;
while(c--){
for(int i = 1; i <= c; i++){
aAP = getAP(i-2);
bAP = getAP(i-1);
cAP = getAP(i);
dAP = getAP(i+1);
aAP = getAP(i-2); // prev
bAP = aAP ? aAP->next : getAP(i-1); // to be compared
cAP = bAP ? bAP->next : getAP(i); // to be compared
dAP = cAP ? cAP->next : getAP(i+1); // next
// a -> b -> c -> d
@@ -52,9 +52,9 @@ void Accesspoints::sortAfterChannel() {
while(c--){
for(int i = 1; i <= c; i++){
aAP = getAP(i-2);
bAP = getAP(i-1);
cAP = getAP(i);
dAP = getAP(i+1);
bAP = aAP ? aAP->next : getAP(i-1);
cAP = bAP ? bAP->next : getAP(i);
dAP = cAP ? cAP->next : getAP(i+1);
if(WiFi.channel(bAP->id) > WiFi.channel(cAP->id)) {
cAP->next = bAP;
@@ -349,8 +349,8 @@ void Accesspoints::internal_deselect(int num) {
void Accesspoints::internal_remove(int num) {
AP* aAP = getAP(num-1); // prev
AP* bAP = getAP(num); // to-delete
AP* cAP = getAP(num+1); // next
AP* bAP = aAP ? aAP->next : getAP(num); // to-delete
AP* cAP = bAP ? bAP->next : getAP(num+1); // next
if(aAP && cAP) { // a -> b -> c = a -> c
aAP->next = cAP; //

View File

@@ -3,7 +3,6 @@
#include "Arduino.h"
#include <ESP8266WiFi.h>
#include <LinkedList.h>
#include "Names.h"
#include "language.h"