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

Commit c6116c3

Browse files
committed
Avoid unnecessary conversions
No need to convert these values, they're already of the right type.
1 parent c363771 commit c6116c3

File tree

14 files changed

+18
-18
lines changed

14 files changed

+18
-18
lines changed

blame.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ func (b *blame) fillGraphAndData() error {
193193
// this first commit.
194194
if i == 0 {
195195
for j := 0; j < nLines; j++ {
196-
b.graph[i][j] = (*object.Commit)(b.revs[i])
196+
b.graph[i][j] = b.revs[i]
197197
}
198198
} else {
199199
// if this is not the first commit, then assign to the old
@@ -211,7 +211,7 @@ func (b *blame) sliceGraph(i int) []*object.Commit {
211211
fVs := b.graph[i]
212212
result := make([]*object.Commit, 0, len(fVs))
213213
for _, v := range fVs {
214-
c := object.Commit(*v)
214+
c := *v
215215
result = append(result, &c)
216216
}
217217
return result
@@ -234,7 +234,7 @@ func (b *blame) assignOrigin(c, p int) {
234234
b.graph[c][dl] = b.graph[p][sl]
235235
case hunks[h].Type == 1:
236236
dl++
237-
b.graph[c][dl] = (*object.Commit)(b.revs[c])
237+
b.graph[c][dl] = b.revs[c]
238238
case hunks[h].Type == -1:
239239
sl++
240240
default:

config/branch.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func (b *Branch) marshal() *format.Subsection {
7272
if b.Rebase == "" {
7373
b.raw.RemoveOption(rebaseKey)
7474
} else {
75-
b.raw.SetOption(rebaseKey, string(b.Rebase))
75+
b.raw.SetOption(rebaseKey, b.Rebase)
7676
}
7777

7878
return b.raw

plumbing/format/commitgraph/file.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ func (fi *fileIndex) getHashesFromIndexes(indexes []int) ([]plumbing.Hash, error
249249
// Hashes returns all the hashes that are available in the index
250250
func (fi *fileIndex) Hashes() []plumbing.Hash {
251251
hashes := make([]plumbing.Hash, fi.fanout[0xff])
252-
for i := 0; i < int(fi.fanout[0xff]); i++ {
252+
for i := 0; i < fi.fanout[0xff]; i++ {
253253
offset := fi.oidLookupOffset + int64(i)*20
254254
if n, err := fi.reader.ReadAt(hashes[i][:], offset); err != nil || n < 20 {
255255
return nil

plumbing/format/commitgraph/memory.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func (mi *MemoryIndex) GetIndexByHash(h plumbing.Hash) (int, error) {
3131
// GetCommitDataByIndex gets the commit node from the commit graph using index
3232
// obtained from child node, if available
3333
func (mi *MemoryIndex) GetCommitDataByIndex(i int) (*CommitData, error) {
34-
if int(i) >= len(mi.commitData) {
34+
if i >= len(mi.commitData) {
3535
return nil, plumbing.ErrObjectNotFound
3636
}
3737

plumbing/format/idxfile/writer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ func (w *Writer) createIndex() (*MemoryIndex, error) {
147147
idx.Offset32[bucket] = append(idx.Offset32[bucket], buf.Bytes()...)
148148

149149
buf.Truncate(0)
150-
binary.WriteUint32(buf, uint32(o.CRC32))
150+
binary.WriteUint32(buf, o.CRC32)
151151
idx.CRC32[bucket] = append(idx.CRC32[bucket], buf.Bytes()...)
152152
}
153153

plumbing/object/patch.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ func printStat(fileStats []FileStat) string {
278278
var scaleFactor float64
279279
if longestTotalChange > heightOfHistogram {
280280
// Scale down to heightOfHistogram.
281-
scaleFactor = float64(longestTotalChange / heightOfHistogram)
281+
scaleFactor = longestTotalChange / heightOfHistogram
282282
} else {
283283
scaleFactor = 1.0
284284
}

plumbing/object/tree.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ func (t *Tree) Encode(o plumbing.EncodedObject) (err error) {
288288
return err
289289
}
290290

291-
if _, err = w.Write([]byte(entry.Hash[:])); err != nil {
291+
if _, err = w.Write(entry.Hash[:]); err != nil {
292292
return err
293293
}
294294
}
@@ -517,4 +517,4 @@ func simpleJoin(parent, child string) string {
517517
return parent + "/" + child
518518
}
519519
return child
520-
}
520+
}

plumbing/protocol/packp/advrefs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func (a *AdvRefs) resolveHead(s storer.ReferenceStorer) error {
107107
return nil
108108
}
109109

110-
ref, err := s.Reference(plumbing.ReferenceName(plumbing.Master))
110+
ref, err := s.Reference(plumbing.Master)
111111

112112
// check first if HEAD is pointing to master
113113
if err == nil {

plumbing/protocol/packp/updreq_decode.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ func parseCommand(b []byte) (*Command, error) {
225225
return nil, errInvalidNewObjId(err)
226226
}
227227

228-
return &Command{Old: oh, New: nh, Name: plumbing.ReferenceName(n)}, nil
228+
return &Command{Old: oh, New: nh, Name: n}, nil
229229
}
230230

231231
func parseHash(s string) (plumbing.Hash, error) {

plumbing/transport/ssh/auth_method.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func (a *KeyboardInteractive) ClientConfig() (*ssh.ClientConfig, error) {
6161
return a.SetHostKeyCallback(&ssh.ClientConfig{
6262
User: a.User,
6363
Auth: []ssh.AuthMethod{
64-
ssh.KeyboardInteractiveChallenge(a.Challenge),
64+
a.Challenge,
6565
},
6666
})
6767
}

0 commit comments

Comments
 (0)