Skip to content
This repository has been archived by the owner on Sep 11, 2020. It is now read-only.

Commit

Permalink
*: avoid unnecessary conversions
Browse files Browse the repository at this point in the history
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 a1d8a7a)
  • Loading branch information
muesli authored and mcuadros committed Jul 29, 2019
1 parent bfe45ee commit e5c9c0d
Show file tree
Hide file tree
Showing 14 changed files with 18 additions and 18 deletions.
6 changes: 3 additions & 3 deletions blame.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion config/branch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion plumbing/format/commitgraph/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion plumbing/format/commitgraph/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion plumbing/format/idxfile/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()...)
}

Expand Down
2 changes: 1 addition & 1 deletion plumbing/object/patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions plumbing/object/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down Expand Up @@ -517,4 +517,4 @@ func simpleJoin(parent, child string) string {
return parent + "/" + child
}
return child
}
}
2 changes: 1 addition & 1 deletion plumbing/protocol/packp/advrefs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion plumbing/protocol/packp/updreq_decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion plumbing/transport/ssh/auth_method.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
})
}
Expand Down
2 changes: 1 addition & 1 deletion utils/merkletrie/difftree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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] {
Expand Down
4 changes: 2 additions & 2 deletions utils/merkletrie/noder/path_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"}})
Expand Down
2 changes: 1 addition & 1 deletion worktree_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion worktree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e5c9c0d

Please sign in to comment.