diff options
author | Uwe Hermann <uwe@hermann-uwe.de> | 2018-05-18 20:14:19 +0200 |
---|---|---|
committer | Uwe Hermann <uwe@hermann-uwe.de> | 2018-05-18 20:54:36 +0200 |
commit | 996b17db506ceb435ae3ed53d4c6ac66e10c7b34 (patch) | |
tree | a9428fd5d16b3e2bf25971bff72cf76203947c08 /type_decoder.c | |
parent | 29adc171b485ff08a737488e84db08eb67a0590a (diff) | |
download | libsigrokdecode-996b17db506ceb435ae3ed53d4c6ac66e10c7b34.tar.gz libsigrokdecode-996b17db506ceb435ae3ed53d4c6ac66e10c7b34.zip |
srd_inst_find_by_obj(): Minor performance improvement.
Handle the most common case of one session and one decoder first so
we can exit early. This has a small, but measurable performance benefit.
Diffstat (limited to 'type_decoder.c')
-rw-r--r-- | type_decoder.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/type_decoder.c b/type_decoder.c index cff242c..59fb049 100644 --- a/type_decoder.c +++ b/type_decoder.c @@ -256,6 +256,12 @@ static inline struct srd_decoder_inst *srd_inst_find_by_obj( struct srd_session *sess; GSList *l; + /* Performance shortcut: Handle the most common case first. */ + sess = sessions->data; + di = sess->di_list->data; + if (di->py_inst == obj) + return di; + di = NULL; for (l = sessions; di == NULL && l != NULL; l = l->next) { sess = l->data; |