Checking first char for null is more efficient than strlen.

This commit is contained in:
Roy Marples 2008-01-21 15:30:40 +00:00
parent 847ccac13c
commit 07728abbc1
5 changed files with 8 additions and 8 deletions

View File

@ -151,7 +151,7 @@ rc_depinfo_t *rc_deptree_load (void)
{ {
/* Sanity */ /* Sanity */
e = get_shell_value (p); e = get_shell_value (p);
if (! e || strlen (e) == 0) if (! e || *e == '\0')
goto next; goto next;
if (! deptree) if (! deptree)
@ -176,7 +176,7 @@ rc_depinfo_t *rc_deptree_load (void)
/* Sanity */ /* Sanity */
e = get_shell_value (p); e = get_shell_value (p);
if (! e || strlen (e) == 0) if (! e || *e == '\0')
goto next; goto next;
if (! deptype) if (! deptype)

View File

@ -196,7 +196,7 @@ char **rc_config_load (const char *file)
do { do {
/* Bash variables are usually quoted */ /* Bash variables are usually quoted */
token = strsep (&line, "\"\'"); token = strsep (&line, "\"\'");
} while ((token) && (strlen (token) == 0)); } while (token && *token == '\0');
/* Drop a newline if that's all we have */ /* Drop a newline if that's all we have */
if (token) { if (token) {

View File

@ -205,7 +205,7 @@ static int do_service (int argc, char **argv)
else else
service = getenv ("SVCNAME"); service = getenv ("SVCNAME");
if (! service || strlen (service) == 0) if (! service || *service == '\0')
eerrorx ("%s: no service specified", applet); eerrorx ("%s: no service specified", applet);
if (strcmp (applet, "service_started") == 0) if (strcmp (applet, "service_started") == 0)
@ -252,7 +252,7 @@ static int do_mark_service (int argc, char **argv)
else else
service = getenv ("SVCNAME"); service = getenv ("SVCNAME");
if (! service || strlen (service) == 0) if (! service || *service == '\0')
eerrorx ("%s: no service specified", applet); eerrorx ("%s: no service specified", applet);
if (strcmp (applet, "mark_service_started") == 0) if (strcmp (applet, "mark_service_started") == 0)
@ -310,7 +310,7 @@ static int do_value (int argc, char **argv)
if (! service) if (! service)
eerrorx ("%s: no service specified", applet); eerrorx ("%s: no service specified", applet);
if (argc < 2 || ! argv[1] || strlen (argv[1]) == 0) if (argc < 2 || ! argv[1] || *argv[1] == '\0')
eerrorx ("%s: no option specified", applet); eerrorx ("%s: no option specified", applet);
if (strcmp (applet, "service_get_value") == 0 || if (strcmp (applet, "service_get_value") == 0 ||

View File

@ -634,7 +634,7 @@ int main (int argc, char **argv)
{ {
switch (opt) { switch (opt) {
case 'o': case 'o':
if (strlen (optarg) == 0) if (*optarg == '\0')
optarg = NULL; optarg = NULL;
exit (set_ksoftlevel (optarg) ? EXIT_SUCCESS : EXIT_FAILURE); exit (set_ksoftlevel (optarg) ? EXIT_SUCCESS : EXIT_FAILURE);
case_RC_COMMON_GETOPT case_RC_COMMON_GETOPT

View File

@ -152,7 +152,7 @@ static int parse_signal (const char *sig)
unsigned int i = 0; unsigned int i = 0;
char *s; char *s;
if (! sig || strlen (sig) == 0) if (! sig || *sig == '\0')
return (-1); return (-1);
if (sscanf (sig, "%u", &i) == 1) { if (sscanf (sig, "%u", &i) == 1) {