chiark / gitweb /
sysv-generator: don't check first if hashmap contains the service name
authorThomas Hindoe Paaboel Andersen <phomes@gmail.com>
Wed, 17 Sep 2014 21:03:27 +0000 (23:03 +0200)
committerThomas Hindoe Paaboel Andersen <phomes@gmail.com>
Wed, 17 Sep 2014 21:11:58 +0000 (23:11 +0200)
Just test if hashmap_get returns null. hashmap_contains does exactly
same thing internally so this is slightly more efficient for the true
case.

Silences a coverity warning too. CID#1237648

src/sysv-generator/sysv-generator.c

index e5902ab8f8180751b4917990b0c3e999948cee0e..43bcaa862fb5c15df767bb7e67461f47754451a9 100644 (file)
@@ -810,9 +810,8 @@ static int set_dependencies_from_rcnd(LookupPaths lp, Hashmap *all_services) {
                                         goto finish;
                                 }
 
                                         goto finish;
                                 }
 
-                                if (hashmap_contains(all_services, name))
-                                        service = hashmap_get(all_services, name);
-                                else {
+                                service = hashmap_get(all_services, name);
+                                if (!service){
                                         log_warning("Could not find init script for %s", name);
                                         continue;
                                 }
                                         log_warning("Could not find init script for %s", name);
                                         continue;
                                 }