Skip to content

Commit b5ad6e9

Browse files
committed
Corrected use of const
1 parent c8a50d5 commit b5ad6e9

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

libraries/BLE/src/BLEAddress.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -62,34 +62,34 @@ bool BLEAddress::equals(BLEAddress otherAddress) {
6262
return memcmp(otherAddress.getNative(), m_address, ESP_BD_ADDR_LEN) == 0;
6363
} // equals
6464

65-
bool BLEAddress::operator==(BLEAddress otherAddress) {
66-
return equals(otherAddress);
65+
bool BLEAddress::operator==(const BLEAddress& otherAddress) const {
66+
return memcmp(otherAddress.m_address, m_address, ESP_BD_ADDR_LEN) == 0;
6767
}
6868

69-
bool BLEAddress::operator!=(BLEAddress otherAddress) {
70-
return ! this == otherAddress;
69+
bool BLEAddress::operator!=(const BLEAddress& otherAddress) const {
70+
return !(*this == otherAddress);
7171
}
7272

73-
bool BLEAddress::operator<(BLEAddress otherAddress) {
74-
return memcmp(otherAddress.getNative(), m_address, ESP_BD_ADDR_LEN) < 0;
73+
bool BLEAddress::operator<(const BLEAddress& otherAddress) const {
74+
return memcmp(otherAddress.m_address, m_address, ESP_BD_ADDR_LEN) < 0;
7575
}
7676

77-
bool BLEAddress::operator<=(BLEAddress otherAddress) {
78-
return !this > otherAddress;
77+
bool BLEAddress::operator<=(const BLEAddress& otherAddress) const {
78+
return !(*this > otherAddress);
7979
}
8080

81-
bool BLEAddress::operator>=(BLEAddress otherAddress) {
82-
return !this < otherAddress;
81+
bool BLEAddress::operator>=(const BLEAddress& otherAddress) const {
82+
return !(*this < otherAddress);
8383
}
8484

85-
bool BLEAddress::operator>(BLEAddress otherAddress) {
86-
return memcmp(otherAddress.getNative(), m_address, ESP_BD_ADDR_LEN) > 0;
85+
bool BLEAddress::operator>(const BLEAddress& otherAddress) const {
86+
return memcmp(otherAddress.m_address, m_address, ESP_BD_ADDR_LEN) > 0;
8787
}
8888

8989
/**
9090
* @brief Return the native representation of the address.
9191
* @return The native representation of the address.
92-
*/
92+
*/
9393
esp_bd_addr_t *BLEAddress::getNative() {
9494
return &m_address;
9595
} // getNative

libraries/BLE/src/BLEAddress.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ class BLEAddress {
2323
BLEAddress(esp_bd_addr_t address);
2424
BLEAddress(std::string stringAddress);
2525
bool equals(BLEAddress otherAddress);
26-
bool operator==(BLEAddress otherAddress);
27-
bool operator!=(BLEAddress otherAddress);
28-
bool operator<(BLEAddress otherAddress);
29-
bool operator<=(BLEAddress otherAddress);
30-
bool operator>(BLEAddress otherAddress);
31-
bool operator>=(BLEAddress otherAddress);
26+
bool operator==(const BLEAddress& otherAddress) const;
27+
bool operator!=(const BLEAddress& otherAddress) const;
28+
bool operator<(const BLEAddress& otherAddress) const;
29+
bool operator<=(const BLEAddress& otherAddress) const;
30+
bool operator>(const BLEAddress& otherAddress) const;
31+
bool operator>=(const BLEAddress& otherAddress) const;
3232
esp_bd_addr_t* getNative();
3333
std::string toString();
3434

0 commit comments

Comments
 (0)