Bluetooth: GATT: Skip ahead if handle is not within service handles
This reduces bt_gatt_foreach_attr complexity (O(n)) so it can skip ahead when the start handle is not within its service handles. Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
parent
1a3d9fa0ba
commit
4154f27ab5
1 changed files with 9 additions and 0 deletions
|
@ -933,6 +933,15 @@ void bt_gatt_foreach_attr(u16_t start_handle, u16_t end_handle,
|
|||
|
||||
SYS_SLIST_FOR_EACH_CONTAINER(&db, svc, node) {
|
||||
int i;
|
||||
struct bt_gatt_service *next;
|
||||
|
||||
next = SYS_SLIST_PEEK_NEXT_CONTAINER(svc, node);
|
||||
if (next) {
|
||||
/* Skip ahead if start is not within service handles */
|
||||
if (next->attrs[0].handle <= start_handle) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < svc->attr_count; i++) {
|
||||
struct bt_gatt_attr *attr = &svc->attrs[i];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue