Skip to content
This repository was archived by the owner on Feb 27, 2018. It is now read-only.

Commit 3abd9ef

Browse files
committed
Use more efficient strings.NewReader
1 parent 7b7b536 commit 3abd9ef

4 files changed

Lines changed: 9 additions & 9 deletions

File tree

virtualbox/dhcp.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package virtualbox
22

33
import (
44
"bufio"
5-
"bytes"
65
"net"
6+
"strings"
77
)
88

99
// DHCP server info.
@@ -47,7 +47,7 @@ func DHCPs() (map[string]*DHCP, error) {
4747
if err != nil {
4848
return nil, err
4949
}
50-
s := bufio.NewScanner(bytes.NewReader([]byte(out)))
50+
s := bufio.NewScanner(strings.NewReader(out))
5151
m := map[string]*DHCP{}
5252
dhcp := &DHCP{}
5353
for s.Scan() {

virtualbox/hostonlynet.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ package virtualbox
22

33
import (
44
"bufio"
5-
"bytes"
65
"errors"
76
"fmt"
87
"net"
98
"regexp"
109
"strconv"
10+
"strings"
1111
)
1212

1313
var (
@@ -72,7 +72,7 @@ func HostonlyNets() (map[string]*HostonlyNet, error) {
7272
if err != nil {
7373
return nil, err
7474
}
75-
s := bufio.NewScanner(bytes.NewReader([]byte(out)))
75+
s := bufio.NewScanner(strings.NewReader(out))
7676
m := map[string]*HostonlyNet{}
7777
n := &HostonlyNet{}
7878
for s.Scan() {

virtualbox/machine.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ package virtualbox
22

33
import (
44
"bufio"
5-
"bytes"
65
"fmt"
76
"path/filepath"
87
"strconv"
8+
"strings"
99
"time"
1010
)
1111

@@ -189,7 +189,7 @@ func GetMachine(id string) (*Machine, error) {
189189
}
190190
return nil, err
191191
}
192-
s := bufio.NewScanner(bytes.NewReader([]byte(stdout)))
192+
s := bufio.NewScanner(strings.NewReader(stdout))
193193
m := &Machine{}
194194
for s.Scan() {
195195
res := reVMInfoLine.FindStringSubmatch(s.Text())
@@ -248,7 +248,7 @@ func ListMachines() ([]*Machine, error) {
248248
return nil, err
249249
}
250250
ms := []*Machine{}
251-
s := bufio.NewScanner(bytes.NewReader([]byte(out)))
251+
s := bufio.NewScanner(strings.NewReader(out))
252252
for s.Scan() {
253253
res := reVMNameUUID.FindStringSubmatch(s.Text())
254254
if res == nil {

virtualbox/natnet.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ package virtualbox
22

33
import (
44
"bufio"
5-
"bytes"
65
"net"
76
"strconv"
7+
"strings"
88
)
99

1010
// A NATNet defines a NAT network.
@@ -22,7 +22,7 @@ func NATNets() (map[string]NATNet, error) {
2222
if err != nil {
2323
return nil, err
2424
}
25-
s := bufio.NewScanner(bytes.NewReader([]byte(out)))
25+
s := bufio.NewScanner(strings.NewReader(out))
2626
m := map[string]NATNet{}
2727
n := NATNet{}
2828
for s.Scan() {

0 commit comments

Comments
 (0)