NetworkManager/shared
Thomas Haller 17d9b852c8 shared: explicitly implement binary search in NM_UTILS_STRING_TABLE_LOOKUP_DEFINE*()
When looking at nm_utils_array_find_binary_search(), we see that binary
search really isn't complicated. In nm_utils_array_find_binary_search()
it looks complicated, because that is our general purpose function which
accepts arbitrary lists, uses an opaque compare function, accepts a user
data argument, and returns the insertion position.

This is unnecessary for the narrow purpose in NM_UTILS_STRING_TABLE_LOOKUP_DEFINE*().
When we inline the binary search, it can be simplified, and the remaining
parts is simple enough to prefer this duplication of binary search over
using our general purpose function.

Also, this gives the compiler more chance for optimization. For
example, we can use "unsigned" as index type instead of gssize, because
we know (at compile time), that this type will always be large enough
for our LIST. Also, we can directly call strcmp().

The result is that the macro's implementation is also fast in the best
case (where the needle is found with only one strcmp()) and in the cases
where there is a small number of items to search.
It thus alleviates concerns that using the macro might be slower than
an optimized implementation.

The binary size of the defined function increases slightly (from 112
bytes to 192 bytes, on x86_64, GCC, -O2). But according to my tests it
is slightly and measurably faster.
2020-02-13 14:49:45 +01:00
..
c-list shared/c-list: reimport 2019-04-14 17:22:04 +02:00
c-rbtree shared/c-rbtree: reimport 2019-04-14 17:23:01 +02:00
c-siphash shared/c-siphash: reimport 2019-04-14 17:23:25 +02:00
c-stdaux shared: patch c-stdaux.h to not include <stdatomic.h> 2019-04-14 17:17:52 +02:00
n-acd n-acd: fix leaking socket handle in n_acd_socket_new() when setsockopt() fails 2019-08-02 11:26:25 +02:00
n-dhcp4 n-dhcp4: avoid double free of NDhcp4Outgoing 2020-02-11 09:26:07 +01:00
nm-glib-aux shared: explicitly implement binary search in NM_UTILS_STRING_TABLE_LOOKUP_DEFINE*() 2020-02-13 14:49:45 +01:00
nm-keyfile all: use nm_utils_ipaddr_is_valid() instead of nm_utils_ipaddr_valid() 2020-01-28 11:17:41 +01:00
nm-libnm-aux clients: in debug builds randomly use sync init of NMClient for testing 2019-12-10 09:17:17 +01:00
nm-libnm-core-aux all: unify format of our Copyright source code comments 2019-10-02 17:03:52 +02:00
nm-libnm-core-intern shared: nm-auth-subject: add unix-session type 2019-12-24 10:13:51 +01:00
nm-std-aux license: relicense "shared/nm-std-aux/nm-dbus-compat.h" under LGPL-2.1+ 2020-01-14 16:54:43 +01:00
nm-udev-aux shared/udev: don't use GIOChannel to watch plain file descriptor 2020-01-13 15:46:04 +01:00
nm-utils shared/tests: add nmtst_get_rand_uint64() util 2020-02-10 19:11:50 +01:00
systemd systemd: merge branch systemd into master 2019-12-16 10:22:09 +01:00
meson.build libnm/keyfile: build keyfile code as separate GPL licensed internal library 2020-01-07 13:17:47 +01:00
nm-default.h libnm: include "nm-libnm-utils.h" by default in libnm sources 2019-10-18 22:09:18 +02:00
nm-meta-setting.c libnm-core,cli: add VRF setting 2020-01-14 09:49:01 +01:00
nm-meta-setting.h libnm-core,cli: add VRF setting 2020-01-14 09:49:01 +01:00
nm-test-libnm-utils.h libnm/tests: extend nmtstc_client_new() to create other GObject types 2020-01-28 10:54:14 +01:00
nm-test-utils-impl.c libnm/tests: cleanup add_device_common() test helper 2020-01-28 10:54:14 +01:00
nm-version-macros.h.in release: bump version to 1.23.0 (development) 2019-11-29 15:46:22 +01:00