3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-10-04 02:18:49 +02:00

client: Optimize network property lookups

This commit is contained in:
Tim Kourt 2018-11-12 09:08:04 -08:00 committed by Denis Kenzior
parent 13c4095b77
commit b0e5b9de02
3 changed files with 20 additions and 26 deletions

View File

@ -44,35 +44,28 @@ static void check_errors_method_callback(struct l_dbus_message *message,
dbus_message_has_error(message); dbus_message_has_error(message);
} }
bool network_is_connected(const char *path) const struct proxy_interface *network_get_proxy(const char *path)
{ {
const struct network *network; return proxy_interface_find(IWD_NETWORK_INTERFACE, path);
const struct proxy_interface *proxy = }
proxy_interface_find(IWD_NETWORK_INTERFACE, path);
network = proxy_interface_get_data(proxy); bool network_is_connected(const struct proxy_interface *network_proxy)
{
const struct network *network = proxy_interface_get_data(network_proxy);
return network->connected; return network->connected;
} }
const char *network_get_type(const char *path) const char *network_get_type(const struct proxy_interface *network_proxy)
{ {
const struct network *network; const struct network *network = proxy_interface_get_data(network_proxy);
const struct proxy_interface *proxy =
proxy_interface_find(IWD_NETWORK_INTERFACE, path);
network = proxy_interface_get_data(proxy);
return network->type; return network->type;
} }
const char *network_get_name(const char *path) const char *network_get_name(const struct proxy_interface *network_proxy)
{ {
const struct network *network; const struct network *network = proxy_interface_get_data(network_proxy);
const struct proxy_interface *proxy =
proxy_interface_find(IWD_NETWORK_INTERFACE, path);
network = proxy_interface_get_data(proxy);
return network->name; return network->name;
} }

View File

@ -25,10 +25,11 @@ struct network_args {
const char *type; const char *type;
}; };
bool network_is_connected(const char *path); const struct proxy_interface *network_get_proxy(const char *path);
const char *network_get_type(const char *path); bool network_is_connected(const struct proxy_interface *network_proxy);
const char *network_get_name(const char *path); const char *network_get_type(const struct proxy_interface *network_proxy);
void network_connect(const struct proxy_interface *proxy); const char *network_get_name(const struct proxy_interface *network_proxy);
void network_connect(const struct proxy_interface *network_proxy);
char *network_name_completion(const struct proxy_interface *device, char *network_name_completion(const struct proxy_interface *device,
const char *text, int state); const char *text, int state);

View File

@ -341,15 +341,15 @@ static void ordered_networks_display(struct l_queue *ordered_networks)
for (is_first = true, entry = l_queue_get_entries(ordered_networks); for (is_first = true, entry = l_queue_get_entries(ordered_networks);
entry; entry = entry->next) { entry; entry = entry->next) {
struct ordered_network *network = entry->data; struct ordered_network *network = entry->data;
const char *network_name = const struct proxy_interface *network_i =
network_get_name(network->network_path); network_get_proxy(network->network_path);
const char *network_type = const char *network_name = network_get_name(network_i);
network_get_type(network->network_path); const char *network_type = network_get_type(network_i);
if (display_signal_as_dbms) if (display_signal_as_dbms)
dbms = l_strdup_printf("%d", network->signal_strength); dbms = l_strdup_printf("%d", network->signal_strength);
if (is_first && network_is_connected(network->network_path)) { if (is_first && network_is_connected(network_i)) {
display("%s%-*s%-*s%-*s%-*s\n", MARGIN, display("%s%-*s%-*s%-*s%-*s\n", MARGIN,
2, COLOR_BOLDGRAY "> " COLOR_OFF, 2, COLOR_BOLDGRAY "> " COLOR_OFF,
32, network_name, 10, network_type, 32, network_name, 10, network_type,