commit b0e5b9de0213e06feee43692d735f4aa474b63e9
parent 13c4095b7737ad2422932755b455485db209949f
Author: Tim Kourt <tim.a.kourt@linux.intel.com>
Date: Mon, 12 Nov 2018 09:08:04 -0800
client: Optimize network property lookups
Diffstat:
3 files changed, 20 insertions(+), 26 deletions(-)
diff --git a/client/network.c b/client/network.c
@@ -44,35 +44,28 @@ static void check_errors_method_callback(struct l_dbus_message *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;
- const struct proxy_interface *proxy =
- proxy_interface_find(IWD_NETWORK_INTERFACE, path);
+ return 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;
}
-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 proxy_interface *proxy =
- proxy_interface_find(IWD_NETWORK_INTERFACE, path);
-
- network = proxy_interface_get_data(proxy);
+ const struct network *network = proxy_interface_get_data(network_proxy);
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 proxy_interface *proxy =
- proxy_interface_find(IWD_NETWORK_INTERFACE, path);
-
- network = proxy_interface_get_data(proxy);
+ const struct network *network = proxy_interface_get_data(network_proxy);
return network->name;
}
diff --git a/client/network.h b/client/network.h
@@ -25,10 +25,11 @@ struct network_args {
const char *type;
};
-bool network_is_connected(const char *path);
-const char *network_get_type(const char *path);
-const char *network_get_name(const char *path);
-void network_connect(const struct proxy_interface *proxy);
+const struct proxy_interface *network_get_proxy(const char *path);
+bool network_is_connected(const struct proxy_interface *network_proxy);
+const char *network_get_type(const struct proxy_interface *network_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,
const char *text, int state);
diff --git a/client/station.c b/client/station.c
@@ -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);
entry; entry = entry->next) {
struct ordered_network *network = entry->data;
- const char *network_name =
- network_get_name(network->network_path);
- const char *network_type =
- network_get_type(network->network_path);
+ const struct proxy_interface *network_i =
+ network_get_proxy(network->network_path);
+ const char *network_name = network_get_name(network_i);
+ const char *network_type = network_get_type(network_i);
if (display_signal_as_dbms)
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,
2, COLOR_BOLDGRAY "> " COLOR_OFF,
32, network_name, 10, network_type,