]> err.no Git - systemd/commitdiff
Speed up udev_enumerate_scan_*
authorMartin Pitt <martin.pitt@ubuntu.com>
Mon, 21 Dec 2009 14:41:25 +0000 (15:41 +0100)
committerMartin Pitt <martin.pitt@ubuntu.com>
Mon, 21 Dec 2009 14:41:25 +0000 (15:41 +0100)
Check property match earlier, to avoid lots of readlink() and stat()
calls when we check property matches.

libudev/libudev-enumerate.c

index 2fcd34829644f9c5defab0cc1b48ce55daf3c498..53cd53b6943a76a2308213d349b8d829c6a17177 100644 (file)
@@ -574,6 +574,8 @@ static int scan_dir_and_add_devices(struct udev_enumerate *udev_enumerate,
                        continue;
 
                util_strscpyl(syspath, sizeof(syspath), path, "/", dent->d_name, NULL);
+               if (!match_property(udev_enumerate, syspath))
+                       continue;
                if (lstat(syspath, &statbuf) != 0)
                        continue;
                if (S_ISREG(statbuf.st_mode))
@@ -586,8 +588,6 @@ static int scan_dir_and_add_devices(struct udev_enumerate *udev_enumerate,
                        continue;
                if (!match_sysattr(udev_enumerate, syspath))
                        continue;
-               if (!match_property(udev_enumerate, syspath))
-                       continue;
                syspath_add(udev_enumerate, syspath);
        }
        closedir(dir);