setCPUSLoadBalancing: optimize
1. Instead of checking for the whole path to contain a substring,
check the file type (to exclude directories right away) and then
a file name only, which is faster.
2. Remove a redundant check.
@@ -79,15 +79,9 @@ func setCPUSLoadBalancing(c *oci.Container, enable bool, schedDomainDir string)
if err != nil {
return err
}
-
- if path == cpuSchedDomainDir {
+ if !info.Mode().IsRegular() || info.Name() != "flags" {
return nil
}
-
- if !strings.Contains(path, "flags") {
- return nil
- }
-
content, err := ioutil.ReadFile(path)
if err != nil {
return err
