We can now just use cached end handle from characteristic instead of calculating it. --- android/gatt.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/android/gatt.c b/android/gatt.c index 18f1a37..15107b9 100644 --- a/android/gatt.c +++ b/android/gatt.c @@ -1979,21 +1979,11 @@ static bool build_descr_cache(int32_t conn_id, struct gatt_device *dev, struct characteristic *ch) { struct discover_desc_data *cb_data; - struct characteristic *next_ch; uint16_t start, end; /* Clip range to given characteristic */ start = ch->ch.value_handle + 1; - end = srvc->primary ? srvc->prim.range.end : srvc->incl.range.end; - - /* Use next characteristic start as end. If there is none - - * service end is valid end. - * TODO: we should cache char end handle to avoid this search - */ - next_ch = queue_find(srvc->chars, match_char_by_higher_inst_id, - INT_TO_PTR(ch->id.instance)); - if (next_ch) - end = next_ch->ch.handle - 1; + end = ch->end_handle; /* If there are no descriptors, notify with fail status. */ if (start > end) -- 1.9.2 -- To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html