Skip to content

Commit b0207eb

Browse files
wopu-otjhedberg
authored andcommitted
Bluetooth: host: Refactor checks in update_ccc for efficiency
Check peer address only if active. Signed-off-by: Wolfgang Puffitsch <[email protected]>
1 parent bec05a5 commit b0207eb

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

subsys/bluetooth/host/gatt.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2009,8 +2009,9 @@ static u8_t update_ccc(const struct bt_gatt_attr *attr, void *user_data)
20092009
ccc = attr->user_data;
20102010

20112011
for (i = 0; i < ARRAY_SIZE(ccc->cfg); i++) {
2012-
/* Ignore configuration for different peer */
2013-
if (bt_conn_addr_le_cmp(conn, &ccc->cfg[i].peer)) {
2012+
/* Ignore configuration for different peer or not active */
2013+
if (!ccc->cfg[i].value ||
2014+
bt_conn_addr_le_cmp(conn, &ccc->cfg[i].peer)) {
20142015
continue;
20152016
}
20162017

@@ -2040,14 +2041,14 @@ static u8_t update_ccc(const struct bt_gatt_attr *attr, void *user_data)
20402041
}
20412042
}
20422043

2043-
if (ccc->cfg[i].value) {
2044-
gatt_ccc_changed(attr, ccc);
2045-
if (IS_ENABLED(CONFIG_BT_GATT_SERVICE_CHANGED) &&
2046-
ccc == &sc_ccc) {
2047-
sc_restore(conn);
2048-
}
2049-
return BT_GATT_ITER_CONTINUE;
2044+
gatt_ccc_changed(attr, ccc);
2045+
2046+
if (IS_ENABLED(CONFIG_BT_GATT_SERVICE_CHANGED) &&
2047+
ccc == &sc_ccc) {
2048+
sc_restore(conn);
20502049
}
2050+
2051+
return BT_GATT_ITER_CONTINUE;
20512052
}
20522053

20532054
return BT_GATT_ITER_CONTINUE;

0 commit comments

Comments
 (0)