OSDN Git Service

android/gatt: Simplify matching functions
authorJakub Tyszkowski <jakub.tyszkowski@tieto.com>
Tue, 1 Apr 2014 08:03:24 +0000 (10:03 +0200)
committerSzymon Janc <szymon.janc@tieto.com>
Tue, 1 Apr 2014 11:41:57 +0000 (13:41 +0200)
We should match uuid from element_id struct to avoid uuid creation every
time.

android/gatt.c

index c825413..bfa43d3 100644 (file)
@@ -229,11 +229,9 @@ static bool match_srvc_by_element_id(const void *data, const void *user_data)
 {
        const struct element_id *exp_id = user_data;
        const struct service *service = data;
-       bt_uuid_t uuid;
 
-       bt_string_to_uuid(&uuid, service->primary.uuid);
        if (service->id.instance == exp_id->instance)
-               return !bt_uuid_cmp(&uuid, &exp_id->uuid);
+               return !bt_uuid_cmp(&service->id.uuid, &exp_id->uuid);
 
        return false;
 }
@@ -277,11 +275,9 @@ static bool match_char_by_element_id(const void *data, const void *user_data)
 {
        const struct element_id *exp_id = user_data;
        const struct characteristic *chars = data;
-       bt_uuid_t uuid;
 
-       bt_string_to_uuid(&uuid, chars->ch.uuid);
        if (exp_id->instance == chars->id.instance)
-               return !bt_uuid_cmp(&uuid, &exp_id->uuid);
+               return !bt_uuid_cmp(&chars->id.uuid, &exp_id->uuid);
 
        return false;
 }