mirror of
https://github.com/opencontainers/runc.git
synced 2025-10-13 03:03:56 +08:00
Refactor enum map range to slice range
grep -r "range map" showw 3 parts use map to range enum types, use slice instead can get better performance and less memory usage. Signed-off-by: Peng Gao <peng.gao.dut@gmail.com>
This commit is contained in:
@@ -223,17 +223,21 @@ func (l *LinuxFactory) Type() string {
|
||||
// This is a low level implementation detail of the reexec and should not be consumed externally
|
||||
func (l *LinuxFactory) StartInitialization() (err error) {
|
||||
var pipefd, rootfd int
|
||||
for k, v := range map[string]*int{
|
||||
"_LIBCONTAINER_INITPIPE": &pipefd,
|
||||
"_LIBCONTAINER_STATEDIR": &rootfd,
|
||||
for _, pair := range []struct {
|
||||
k string
|
||||
v *int
|
||||
}{
|
||||
{"_LIBCONTAINER_INITPIPE", &pipefd},
|
||||
{"_LIBCONTAINER_STATEDIR", &rootfd},
|
||||
} {
|
||||
s := os.Getenv(k)
|
||||
|
||||
s := os.Getenv(pair.k)
|
||||
|
||||
i, err := strconv.Atoi(s)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to convert %s=%s to int", k, s)
|
||||
return fmt.Errorf("unable to convert %s=%s to int", pair.k, s)
|
||||
}
|
||||
*v = i
|
||||
*pair.v = i
|
||||
}
|
||||
var (
|
||||
pipe = os.NewFile(uintptr(pipefd), "pipe")
|
||||
|
Reference in New Issue
Block a user