containerd/integration
Sebastiaan van Stijn eaedadbed0
replace strings.Split(N) for strings.Cut() or alternatives
Go 1.18 and up now provides a strings.Cut() which is better suited for
splitting key/value pairs (and similar constructs), and performs better:

```go
func BenchmarkSplit(b *testing.B) {
        b.ReportAllocs()
        data := []string{"12hello=world", "12hello=", "12=hello", "12hello"}
        for i := 0; i < b.N; i++ {
                for _, s := range data {
                        _ = strings.SplitN(s, "=", 2)[0]
                }
        }
}

func BenchmarkCut(b *testing.B) {
        b.ReportAllocs()
        data := []string{"12hello=world", "12hello=", "12=hello", "12hello"}
        for i := 0; i < b.N; i++ {
                for _, s := range data {
                        _, _, _ = strings.Cut(s, "=")
                }
        }
}
```

    BenchmarkSplit
    BenchmarkSplit-10            8244206               128.0 ns/op           128 B/op          4 allocs/op
    BenchmarkCut
    BenchmarkCut-10             54411998                21.80 ns/op            0 B/op          0 allocs/op

While looking at occurrences of `strings.Split()`, I also updated some for alternatives,
or added some constraints; for cases where an specific number of items is expected, I used `strings.SplitN()`
with a suitable limit. This prevents (theoretical) unlimited splits.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-11-07 10:02:25 +01:00
..
client Add tracing spans in CRI image service and pull.go 2022-11-03 17:03:43 +00:00
cri-api/pkg/apis feat: enable cri remote client to call with grpc calloptions 2021-09-30 23:02:53 +08:00
failpoint/cmd Run gofmt 1.19 2022-08-04 18:18:33 -07:00
images feat: upgrade registry.k8s.io/pause version 2022-09-06 15:59:20 +08:00
remote Rename Size_ to Size 2022-04-22 15:31:53 +00:00
addition_gids_test.go Use image lists in client tests 2022-07-25 10:47:00 -07:00
build_local_containerd_helper_test_linux.go Add sandbox to in memory services 2022-07-29 16:08:07 -07:00
build_local_containerd_helper_test.go Use logtest if possible to clean up logs 2022-10-17 16:27:23 +00:00
container_log_test.go replace strings.Split(N) for strings.Cut() or alternatives 2022-11-07 10:02:25 +01:00
container_restart_test.go Fix command line parsing for image list 2022-07-25 14:19:40 -07:00
container_stats_test.go Fix command line parsing for image list 2022-07-25 14:19:40 -07:00
container_stop_test.go Use image lists in client tests 2022-07-25 10:47:00 -07:00
container_update_resources_test.go integration: TestUpdateContainerResources_MemoryLimit: remove TODO comment 2022-09-05 09:52:29 +02:00
container_volume_test.go Use image lists in client tests 2022-07-25 10:47:00 -07:00
container_without_image_ref_test.go Use image lists in client tests 2022-07-25 10:47:00 -07:00
containerd_image_test.go ContainerStatus to return container resources 2022-08-24 19:08:06 +00:00
duplicate_name_test.go Fix command line parsing for image list 2022-07-25 14:19:40 -07:00
image_load_test.go Use image lists in client tests 2022-07-25 10:47:00 -07:00
image_pull_timeout_test.go Use logtest if possible to clean up logs 2022-10-17 16:27:23 +00:00
imagefs_info_test.go Use image lists in client tests 2022-07-25 10:47:00 -07:00
main_test.go replace strings.Split(N) for strings.Cut() or alternatives 2022-11-07 10:02:25 +01:00
no_metadata_test.go Merge pull request #5619 from mikebrow/cri-add-v1-proxy-alpha 2021-07-09 14:07:24 -04:00
pod_dualstack_test.go Use image lists in client tests 2022-07-25 10:47:00 -07:00
pod_hostname_test.go Use image lists in client tests 2022-07-25 10:47:00 -07:00
restart_test.go Update container with sandbox metadata after NetNS is created 2022-10-09 01:14:08 +00:00
runtime_handler_test.go integration: Enables TestRuntimeHandler for Windows 2021-10-07 18:20:59 -07:00
sandbox_clean_remove_test.go refactor: move from io/ioutil to io and os package 2021-09-21 09:50:38 +08:00
sandbox_clean_remove_windows_test.go Drop deprecated ioutil 2022-07-23 08:36:20 -07:00
sandbox_run_rollback_test.go replace strings.Split(N) for strings.Cut() or alternatives 2022-11-07 10:02:25 +01:00
shim_dial_unix_test.go test: use T.TempDir to create temporary test directory 2022-03-15 14:03:50 +08:00
truncindex_test.go Use image lists in client tests 2022-07-25 10:47:00 -07:00
volume_copy_up_test.go Use image lists in client tests 2022-07-25 10:47:00 -07:00
volume_copy_up_unix_test.go Replace find with native Go code 2021-12-07 11:04:38 +00:00
volume_copy_up_windows_test.go Replace find with native Go code 2021-12-07 11:04:38 +00:00
windows_device_test.go Update image references for Windows tests 2022-07-25 11:04:59 -07:00
windows_hostprocess_test.go Windows HostProcess container CRI stats test 2022-07-27 15:45:37 -07:00
windows_rootfs_size_test.go Update image references for Windows tests 2022-07-25 11:04:59 -07:00