From f30946e1567343ea00bddf3f3008f70cc58e6256 Mon Sep 17 00:00:00 2001 From: Robert Love Date: Tue, 31 Jan 2006 18:52:06 +0000 Subject: [PATCH] 2006-01-31 Robert Love * src/NetworkManagerAP.c: Optimize the function nm_ap_has_manufacturer_default_essid(). I did not like its resulting machine code. This is the first in a series of code tweaks aiming to generate better machine code and make NetworkManager all the better. Just kidding. Who has time to go through the assembly generated for every function? I certainly don't. I have a wife, a kid, a job, a mortgage, a mistress. But this function was so bad, I was called to arms. Like the book. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1418 4912f4e0-d625-0410-9fb7-b9a5a253dbdc --- ChangeLog | 11 +++++++++++ src/NetworkManagerAP.c | 11 ++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4e9fde0f3c..319cd93cb1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2006-01-31 Robert Love + + * src/NetworkManagerAP.c: Optimize the function + nm_ap_has_manufacturer_default_essid(). I did not like its resulting + machine code. This is the first in a series of code tweaks aiming to + generate better machine code and make NetworkManager all the better. + Just kidding. Who has time to go through the assembly generated for + every function? I certainly don't. I have a wife, a kid, a job, + a mortgage, a mistress. But this function was so bad, I was called + to arms. Like the book. + 2006-01-31 Robert Love * src/nm-device-802-11-wireless.c: Set "scan_ssid 1" if the requested diff --git a/src/NetworkManagerAP.c b/src/NetworkManagerAP.c index 9f9f9d71cb..358a8d3e12 100644 --- a/src/NetworkManagerAP.c +++ b/src/NetworkManagerAP.c @@ -57,7 +57,7 @@ struct NMAccessPoint }; /* This is a controlled list. Want to add to it? Stop. Ask first. */ -static char* default_essid_list[] = +static const char * default_essid_list[] = { "linksys", "default", @@ -522,14 +522,15 @@ void nm_ap_set_user_addresses (NMAccessPoint *ap, GSList *list) gboolean nm_ap_has_manufacturer_default_essid (NMAccessPoint *ap) { - int i; + const char **default_essid = default_essid_list; + const char *this_essid; g_return_val_if_fail (ap != NULL, FALSE); + this_essid = ap->essid; - for (i = 0; default_essid_list[i] != NULL; i++) + while (*default_essid) { - char *essid = default_essid_list[i]; - if (strcmp (essid, ap->essid) == 0) + if (!strcmp (*(default_essid++), this_essid)) return TRUE; }