Bluetooth: host: Refactor checks in update_ccc for efficiency

Check peer address only if active.

Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
This commit is contained in:
Wolfgang Puffitsch 2019-11-08 14:27:48 +01:00 committed by Johan Hedberg
parent bec05a5d7f
commit b0207eb778

View file

@ -2009,8 +2009,9 @@ static u8_t update_ccc(const struct bt_gatt_attr *attr, void *user_data)
ccc = attr->user_data;
for (i = 0; i < ARRAY_SIZE(ccc->cfg); i++) {
/* Ignore configuration for different peer */
if (bt_conn_addr_le_cmp(conn, &ccc->cfg[i].peer)) {
/* Ignore configuration for different peer or not active */
if (!ccc->cfg[i].value ||
bt_conn_addr_le_cmp(conn, &ccc->cfg[i].peer)) {
continue;
}
@ -2040,14 +2041,14 @@ static u8_t update_ccc(const struct bt_gatt_attr *attr, void *user_data)
}
}
if (ccc->cfg[i].value) {
gatt_ccc_changed(attr, ccc);
if (IS_ENABLED(CONFIG_BT_GATT_SERVICE_CHANGED) &&
ccc == &sc_ccc) {
sc_restore(conn);
}
return BT_GATT_ITER_CONTINUE;
gatt_ccc_changed(attr, ccc);
if (IS_ENABLED(CONFIG_BT_GATT_SERVICE_CHANGED) &&
ccc == &sc_ccc) {
sc_restore(conn);
}
return BT_GATT_ITER_CONTINUE;
}
return BT_GATT_ITER_CONTINUE;