Minor improvement for memory allocations

This commit is contained in:
Wojciech Tyczynski
2017-05-24 13:52:07 +02:00
parent cc432dbc77
commit 1242e8ca20
2 changed files with 21 additions and 5 deletions

View File

@@ -52,7 +52,9 @@ func GetChainLines(table Table, save []byte) map[Chain]string {
} else if strings.HasPrefix(line, "#") {
continue
} else if strings.HasPrefix(line, ":") && len(line) > 1 {
chain := Chain(strings.SplitN(line[1:], " ", 2)[0])
// We assume that the <line> contains space - chain lines have 3 fields,
// space delimited. If there is no space, this line will panic.
chain := Chain(line[1:strings.Index(line, " ")])
chainsMap[chain] = line
}
}