Fix unnecessary allocations due to Index calls
This commit is contained in:
parent
fea886b223
commit
b849cfc18c
12
.deepsource.toml
Normal file
12
.deepsource.toml
Normal file
@ -0,0 +1,12 @@
|
||||
version = 1
|
||||
|
||||
test_patterns = ["**/*_test.go"]
|
||||
|
||||
exclude_patterns = ["scripts/**"]
|
||||
|
||||
[[analyzers]]
|
||||
name = "go"
|
||||
enabled = true
|
||||
|
||||
[analyzers.meta]
|
||||
import_paths = ["github.com/beego/beego"]
|
||||
@ -15,6 +15,7 @@
|
||||
package httplib
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
@ -261,7 +262,7 @@ func TestToFile(t *testing.T) {
|
||||
}
|
||||
defer os.Remove(f)
|
||||
b, err := ioutil.ReadFile(f)
|
||||
if n := strings.Index(string(b), "origin"); n == -1 {
|
||||
if n := bytes.Index(b, []byte("origin")); n == -1 {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
@ -275,7 +276,7 @@ func TestToFileDir(t *testing.T) {
|
||||
}
|
||||
defer os.RemoveAll("./files")
|
||||
b, err := ioutil.ReadFile(f)
|
||||
if n := strings.Index(string(b), "origin"); n == -1 {
|
||||
if n := bytes.Index(b, []byte("origin")); n == -1 {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
package httplib
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
@ -259,7 +260,7 @@ func TestToFile(t *testing.T) {
|
||||
}
|
||||
defer os.Remove(f)
|
||||
b, err := ioutil.ReadFile(f)
|
||||
if n := strings.Index(string(b), "origin"); n == -1 {
|
||||
if n := bytes.Index(b, []byte("origin")); n == -1 {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
@ -273,7 +274,7 @@ func TestToFileDir(t *testing.T) {
|
||||
}
|
||||
defer os.RemoveAll("./files")
|
||||
b, err := ioutil.ReadFile(f)
|
||||
if n := strings.Index(string(b), "origin"); n == -1 {
|
||||
if n := bytes.Index(b, []byte("origin")); n == -1 {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user