perf: add prealloc (#1846)

pull/1849/head
Sasha Melentyev 3 years ago committed by GitHub
parent da147b5763
commit 48d407cc9b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      cmd/protoc-gen-go-http/http.go
  2. 2
      contrib/config/etcd/config.go
  3. 2
      examples/blog/internal/data/article.go

@ -236,8 +236,8 @@ func replacePath(name string, value string, path string) string {
}
func camelCaseVars(s string) string {
vars := make([]string, 0)
subs := strings.Split(s, ".")
vars := make([]string, 0, len(subs))
for _, sub := range subs {
vars = append(vars, camelCase(sub))
}

@ -77,7 +77,7 @@ func (s *source) Load() ([]*config.KeyValue, error) {
if err != nil {
return nil, err
}
kvs := make([]*config.KeyValue, 0)
kvs := make([]*config.KeyValue, 0, len(rsp.Kvs))
for _, item := range rsp.Kvs {
k := string(item.Key)
kvs = append(kvs, &config.KeyValue{

@ -26,7 +26,7 @@ func (ar *articleRepo) ListArticle(ctx context.Context) ([]*biz.Article, error)
if err != nil {
return nil, err
}
rv := make([]*biz.Article, 0)
rv := make([]*biz.Article, 0, len(ps))
for _, p := range ps {
rv = append(rv, &biz.Article{
ID: p.ID,

Loading…
Cancel
Save