diff options
author | Christian Grothoff <christian@grothoff.org> | 2019-06-01 00:58:06 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2019-06-01 00:58:06 +0200 |
commit | 9f03df3be26e78853cc0d2288d2260b9032126cb (patch) | |
tree | 3f3809083ed421258532aa0411501afc0941e80c /src/identity | |
parent | 47a7c12c47fa10728494623ea8f89beab8e5cd77 (diff) | |
download | gnunet-9f03df3be26e78853cc0d2288d2260b9032126cb.tar.gz gnunet-9f03df3be26e78853cc0d2288d2260b9032126cb.zip |
improve performance of identity_api_lookup.c logic to not be O(n)
Diffstat (limited to 'src/identity')
-rw-r--r-- | src/identity/identity_api.c | 2 | ||||
-rw-r--r-- | src/identity/test_identity_defaults.c | 26 |
2 files changed, 27 insertions, 1 deletions
diff --git a/src/identity/identity_api.c b/src/identity/identity_api.c index fa7c8b023..c463da641 100644 --- a/src/identity/identity_api.c +++ b/src/identity/identity_api.c | |||
@@ -596,6 +596,7 @@ GNUNET_IDENTITY_get (struct GNUNET_IDENTITY_Handle *h, | |||
596 | 596 | ||
597 | if (NULL == h->mq) | 597 | if (NULL == h->mq) |
598 | return NULL; | 598 | return NULL; |
599 | GNUNET_assert (NULL != h->cb); | ||
599 | slen = strlen (service_name) + 1; | 600 | slen = strlen (service_name) + 1; |
600 | if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof (struct GetDefaultMessage)) | 601 | if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof (struct GetDefaultMessage)) |
601 | { | 602 | { |
@@ -641,6 +642,7 @@ GNUNET_IDENTITY_set (struct GNUNET_IDENTITY_Handle *h, | |||
641 | 642 | ||
642 | if (NULL == h->mq) | 643 | if (NULL == h->mq) |
643 | return NULL; | 644 | return NULL; |
645 | GNUNET_assert (NULL != h->cb); | ||
644 | slen = strlen (service_name) + 1; | 646 | slen = strlen (service_name) + 1; |
645 | if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof (struct SetDefaultMessage)) | 647 | if (slen >= GNUNET_MAX_MESSAGE_SIZE - sizeof (struct SetDefaultMessage)) |
646 | { | 648 | { |
diff --git a/src/identity/test_identity_defaults.c b/src/identity/test_identity_defaults.c index ecda31c4c..71e70e7ba 100644 --- a/src/identity/test_identity_defaults.c +++ b/src/identity/test_identity_defaults.c | |||
@@ -149,6 +149,30 @@ get_cb (void *cls, | |||
149 | 149 | ||
150 | 150 | ||
151 | /** | 151 | /** |
152 | * Called with events about egos. | ||
153 | * | ||
154 | * @param cls NULL | ||
155 | * @param ego ego handle | ||
156 | * @param ego_ctx context for application to store data for this ego | ||
157 | * (during the lifetime of this process, initially NULL) | ||
158 | * @param identifier identifier assigned by the user for this ego, | ||
159 | * NULL if the user just deleted the ego and it | ||
160 | * must thus no longer be used | ||
161 | */ | ||
162 | static void | ||
163 | dummy_cb (void *cls, | ||
164 | struct GNUNET_IDENTITY_Ego *ego, | ||
165 | void **ctx, | ||
166 | const char *identifier) | ||
167 | { | ||
168 | (void) cls; | ||
169 | (void) ego; | ||
170 | (void) ctx; | ||
171 | (void) identifier; | ||
172 | } | ||
173 | |||
174 | |||
175 | /** | ||
152 | * Main function of the test, run from scheduler. | 176 | * Main function of the test, run from scheduler. |
153 | * | 177 | * |
154 | * @param cls NULL | 178 | * @param cls NULL |
@@ -162,7 +186,7 @@ run_get (void *cls, | |||
162 | { | 186 | { |
163 | endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &endbadly, NULL); | 187 | endbadly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &endbadly, NULL); |
164 | GNUNET_SCHEDULER_add_shutdown (&cleanup, NULL); | 188 | GNUNET_SCHEDULER_add_shutdown (&cleanup, NULL); |
165 | h = GNUNET_IDENTITY_connect (cfg, NULL, NULL); | 189 | h = GNUNET_IDENTITY_connect (cfg, &dummy_cb, NULL); |
166 | CHECK (NULL != h); | 190 | CHECK (NULL != h); |
167 | op = GNUNET_IDENTITY_get (h, "test-service", &get_cb, NULL); | 191 | op = GNUNET_IDENTITY_get (h, "test-service", &get_cb, NULL); |
168 | } | 192 | } |