فهرست منبع

daemon/graphdriver/windows: use strings.EqualFold()

Saves some allocations

    BenchmarkTolower
    BenchmarkTolower-5     7917788       150.4 ns/op      16 B/op       3 allocs/op
    BenchmarkEqualFold
    BenchmarkEqualFold-5   8248605       143.5 ns/op       8 B/op       1 allocs/op

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn 2 سال پیش
والد
کامیت
9db5dc9a46
1فایلهای تغییر یافته به همراه5 افزوده شده و 6 حذف شده
  1. 5 6
      daemon/graphdriver/windows/windows.go

+ 5 - 6
daemon/graphdriver/windows/windows.go

@@ -103,7 +103,7 @@ func InitFilter(home string, options []string, _ idtools.IdentityMapping) (graph
 	if err != nil {
 	if err != nil {
 		return nil, err
 		return nil, err
 	}
 	}
-	if strings.ToLower(fsType) == "refs" {
+	if strings.EqualFold(fsType, "refs") {
 		return nil, fmt.Errorf("%s is on an ReFS volume - ReFS volumes are not supported", home)
 		return nil, fmt.Errorf("%s is on an ReFS volume - ReFS volumes are not supported", home)
 	}
 	}
 
 
@@ -937,13 +937,12 @@ func (d *Driver) DiffGetter(id string) (graphdriver.FileGetCloser, error) {
 }
 }
 
 
 func parseStorageOpt(storageOpt map[string]string) (*storageOptions, error) {
 func parseStorageOpt(storageOpt map[string]string) (*storageOptions, error) {
-	options := storageOptions{}
+	options := &storageOptions{}
 
 
 	// Read size to change the block device size per container.
 	// Read size to change the block device size per container.
 	for key, val := range storageOpt {
 	for key, val := range storageOpt {
-		key := strings.ToLower(key)
-		switch key {
-		case "size":
+		// FIXME(thaJeztah): options should not be case-insensitive
+		if strings.EqualFold(key, "size") {
 			size, err := units.RAMInBytes(val)
 			size, err := units.RAMInBytes(val)
 			if err != nil {
 			if err != nil {
 				return nil, err
 				return nil, err
@@ -951,5 +950,5 @@ func parseStorageOpt(storageOpt map[string]string) (*storageOptions, error) {
 			options.size = uint64(size)
 			options.size = uint64(size)
 		}
 		}
 	}
 	}
-	return &options, nil
+	return options, nil
 }
 }