aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Muehlhaeuser <muesli@gmail.com>2019-07-21 06:24:22 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2019-07-29 17:34:49 +0200
commite5c9c0dd9ff1f42dcdaba7a51919cf43abdb79f9 (patch)
treeb6e968170f14360f8ed6bc5820788db847ba93b9
parentbfe45eef34bfad73dc9c5255ac8f06ae19501554 (diff)
downloadgo-git-e5c9c0dd9ff1f42dcdaba7a51919cf43abdb79f9.tar.gz
*: avoid unnecessary conversions
No need to convert these values, they're already of the right type. Signed-off-by: Christian Muehlhaeuser <muesli@gmail.com> (cherry picked from commit a1d8a7ac8bd0e4aff0f27dbb8bb37b8bd13a1346)
-rw-r--r--blame.go6
-rw-r--r--config/branch.go2
-rw-r--r--plumbing/format/commitgraph/file.go2
-rw-r--r--plumbing/format/commitgraph/memory.go2
-rw-r--r--plumbing/format/idxfile/writer.go2
-rw-r--r--plumbing/object/patch.go2
-rw-r--r--plumbing/object/tree.go4
-rw-r--r--plumbing/protocol/packp/advrefs.go2
-rw-r--r--plumbing/protocol/packp/updreq_decode.go2
-rw-r--r--plumbing/transport/ssh/auth_method.go2
-rw-r--r--utils/merkletrie/difftree_test.go2
-rw-r--r--utils/merkletrie/noder/path_test.go4
-rw-r--r--worktree_linux.go2
-rw-r--r--worktree_test.go2
14 files changed, 18 insertions, 18 deletions
diff --git a/blame.go b/blame.go
index adb72d5..f610851 100644
--- a/blame.go
+++ b/blame.go
@@ -193,7 +193,7 @@ func (b *blame) fillGraphAndData() error {
// this first commit.
if i == 0 {
for j := 0; j < nLines; j++ {
- b.graph[i][j] = (*object.Commit)(b.revs[i])
+ b.graph[i][j] = b.revs[i]
}
} else {
// if this is not the first commit, then assign to the old
@@ -211,7 +211,7 @@ func (b *blame) sliceGraph(i int) []*object.Commit {
fVs := b.graph[i]
result := make([]*object.Commit, 0, len(fVs))
for _, v := range fVs {
- c := object.Commit(*v)
+ c := *v
result = append(result, &c)
}
return result
@@ -234,7 +234,7 @@ func (b *blame) assignOrigin(c, p int) {
b.graph[c][dl] = b.graph[p][sl]
case hunks[h].Type == 1:
dl++
- b.graph[c][dl] = (*object.Commit)(b.revs[c])
+ b.graph[c][dl] = b.revs[c]
case hunks[h].Type == -1:
sl++
default:
diff --git a/config/branch.go b/config/branch.go
index af61bbb..20dde6e 100644
--- a/config/branch.go
+++ b/config/branch.go
@@ -72,7 +72,7 @@ func (b *Branch) marshal() *format.Subsection {
if b.Rebase == "" {
b.raw.RemoveOption(rebaseKey)
} else {
- b.raw.SetOption(rebaseKey, string(b.Rebase))
+ b.raw.SetOption(rebaseKey, b.Rebase)
}
return b.raw
diff --git a/plumbing/format/commitgraph/file.go b/plumbing/format/commitgraph/file.go
index 175d279..1f82abd 100644
--- a/plumbing/format/commitgraph/file.go
+++ b/plumbing/format/commitgraph/file.go
@@ -249,7 +249,7 @@ func (fi *fileIndex) getHashesFromIndexes(indexes []int) ([]plumbing.Hash, error
// Hashes returns all the hashes that are available in the index
func (fi *fileIndex) Hashes() []plumbing.Hash {
hashes := make([]plumbing.Hash, fi.fanout[0xff])
- for i := 0; i < int(fi.fanout[0xff]); i++ {
+ for i := 0; i < fi.fanout[0xff]; i++ {
offset := fi.oidLookupOffset + int64(i)*20
if n, err := fi.reader.ReadAt(hashes[i][:], offset); err != nil || n < 20 {
return nil
diff --git a/plumbing/format/commitgraph/memory.go b/plumbing/format/commitgraph/memory.go
index a4a96e9..f5afd4c 100644
--- a/plumbing/format/commitgraph/memory.go
+++ b/plumbing/format/commitgraph/memory.go
@@ -31,7 +31,7 @@ func (mi *MemoryIndex) GetIndexByHash(h plumbing.Hash) (int, error) {
// GetCommitDataByIndex gets the commit node from the commit graph using index
// obtained from child node, if available
func (mi *MemoryIndex) GetCommitDataByIndex(i int) (*CommitData, error) {
- if int(i) >= len(mi.commitData) {
+ if i >= len(mi.commitData) {
return nil, plumbing.ErrObjectNotFound
}
diff --git a/plumbing/format/idxfile/writer.go b/plumbing/format/idxfile/writer.go
index aa919e7..fcc78c5 100644
--- a/plumbing/format/idxfile/writer.go
+++ b/plumbing/format/idxfile/writer.go
@@ -147,7 +147,7 @@ func (w *Writer) createIndex() (*MemoryIndex, error) {
idx.Offset32[bucket] = append(idx.Offset32[bucket], buf.Bytes()...)
buf.Truncate(0)
- binary.WriteUint32(buf, uint32(o.CRC32))
+ binary.WriteUint32(buf, o.CRC32)
idx.CRC32[bucket] = append(idx.CRC32[bucket], buf.Bytes()...)
}
diff --git a/plumbing/object/patch.go b/plumbing/object/patch.go
index 1efd0b1..32454ac 100644
--- a/plumbing/object/patch.go
+++ b/plumbing/object/patch.go
@@ -278,7 +278,7 @@ func printStat(fileStats []FileStat) string {
var scaleFactor float64
if longestTotalChange > heightOfHistogram {
// Scale down to heightOfHistogram.
- scaleFactor = float64(longestTotalChange / heightOfHistogram)
+ scaleFactor = longestTotalChange / heightOfHistogram
} else {
scaleFactor = 1.0
}
diff --git a/plumbing/object/tree.go b/plumbing/object/tree.go
index d30cf6e..d0b4fff 100644
--- a/plumbing/object/tree.go
+++ b/plumbing/object/tree.go
@@ -288,7 +288,7 @@ func (t *Tree) Encode(o plumbing.EncodedObject) (err error) {
return err
}
- if _, err = w.Write([]byte(entry.Hash[:])); err != nil {
+ if _, err = w.Write(entry.Hash[:]); err != nil {
return err
}
}
@@ -517,4 +517,4 @@ func simpleJoin(parent, child string) string {
return parent + "/" + child
}
return child
-} \ No newline at end of file
+}
diff --git a/plumbing/protocol/packp/advrefs.go b/plumbing/protocol/packp/advrefs.go
index 684e76a..487ee19 100644
--- a/plumbing/protocol/packp/advrefs.go
+++ b/plumbing/protocol/packp/advrefs.go
@@ -107,7 +107,7 @@ func (a *AdvRefs) resolveHead(s storer.ReferenceStorer) error {
return nil
}
- ref, err := s.Reference(plumbing.ReferenceName(plumbing.Master))
+ ref, err := s.Reference(plumbing.Master)
// check first if HEAD is pointing to master
if err == nil {
diff --git a/plumbing/protocol/packp/updreq_decode.go b/plumbing/protocol/packp/updreq_decode.go
index c15d49c..51e8183 100644
--- a/plumbing/protocol/packp/updreq_decode.go
+++ b/plumbing/protocol/packp/updreq_decode.go
@@ -225,7 +225,7 @@ func parseCommand(b []byte) (*Command, error) {
return nil, errInvalidNewObjId(err)
}
- return &Command{Old: oh, New: nh, Name: plumbing.ReferenceName(n)}, nil
+ return &Command{Old: oh, New: nh, Name: n}, nil
}
func parseHash(s string) (plumbing.Hash, error) {
diff --git a/plumbing/transport/ssh/auth_method.go b/plumbing/transport/ssh/auth_method.go
index dbb47c5..1e5c383 100644
--- a/plumbing/transport/ssh/auth_method.go
+++ b/plumbing/transport/ssh/auth_method.go
@@ -61,7 +61,7 @@ func (a *KeyboardInteractive) ClientConfig() (*ssh.ClientConfig, error) {
return a.SetHostKeyCallback(&ssh.ClientConfig{
User: a.User,
Auth: []ssh.AuthMethod{
- ssh.KeyboardInteractiveChallenge(a.Challenge),
+ a.Challenge,
},
})
}
diff --git a/utils/merkletrie/difftree_test.go b/utils/merkletrie/difftree_test.go
index ac86145..f725bcf 100644
--- a/utils/merkletrie/difftree_test.go
+++ b/utils/merkletrie/difftree_test.go
@@ -177,7 +177,7 @@ func newChangesFromString(s string) (changes, error) {
for _, chunk := range strings.Split(s, " ") {
change := change{
- path: string(chunk[1:]),
+ path: chunk[1:],
}
switch chunk[0] {
diff --git a/utils/merkletrie/noder/path_test.go b/utils/merkletrie/noder/path_test.go
index f49f028..f65b1d5 100644
--- a/utils/merkletrie/noder/path_test.go
+++ b/utils/merkletrie/noder/path_test.go
@@ -154,8 +154,8 @@ func (s *PathSuite) TestCompareMixedDepths(c *C) {
}
func (s *PathSuite) TestCompareNormalization(c *C) {
- p1 := Path([]Noder{&noderMock{name: norm.Form(norm.NFKC).String("페")}})
- p2 := Path([]Noder{&noderMock{name: norm.Form(norm.NFKD).String("페")}})
+ p1 := Path([]Noder{&noderMock{name: norm.NFKC.String("페")}})
+ p2 := Path([]Noder{&noderMock{name: norm.NFKD.String("페")}})
c.Assert(p1.Compare(p2), Equals, 1)
c.Assert(p2.Compare(p1), Equals, -1)
p1 = Path([]Noder{&noderMock{name: "TestAppWithUnicodéPath"}})
diff --git a/worktree_linux.go b/worktree_linux.go
index 891cb1c..efb01b5 100644
--- a/worktree_linux.go
+++ b/worktree_linux.go
@@ -12,7 +12,7 @@ import (
func init() {
fillSystemInfo = func(e *index.Entry, sys interface{}) {
if os, ok := sys.(*syscall.Stat_t); ok {
- e.CreatedAt = time.Unix(int64(os.Ctim.Sec), int64(os.Ctim.Nsec))
+ e.CreatedAt = time.Unix(os.Ctim.Sec, os.Ctim.Nsec)
e.Dev = uint32(os.Dev)
e.Inode = uint32(os.Ino)
e.GID = os.Gid
diff --git a/worktree_test.go b/worktree_test.go
index 1f87957..dab1c23 100644
--- a/worktree_test.go
+++ b/worktree_test.go
@@ -432,7 +432,7 @@ func (s *WorktreeSuite) TestFilenameNormalization(c *C) {
err = w.Filesystem.Remove(filename)
c.Assert(err, IsNil)
- modFilename := norm.Form(norm.NFKD).String(filename)
+ modFilename := norm.NFKD.String(filename)
writeFile(modFilename)
_, err = w.Add(filename)