aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/format/index
diff options
context:
space:
mode:
authorferhat elmas <elmas.ferhat@gmail.com>2017-11-29 02:24:31 +0100
committerferhat elmas <elmas.ferhat@gmail.com>2017-11-29 13:01:32 +0100
commit18e6f9daa3899318d36b525b068837f49bc2c1cf (patch)
treea797b79d0a750972ba9809eb52691cb09f9b6383 /plumbing/format/index
parentc07c778ed043429427533e2fd7549a3d54b903f1 (diff)
downloadgo-git-18e6f9daa3899318d36b525b068837f49bc2c1cf.tar.gz
all: simplification
- no length for map initialization - don't check for boolean/error return - don't format string - use string method of bytes buffer instead of converting bytes to string - use `strings.Contains` instead of `strings.Index` - use `bytes.Equal` instead of `bytes.Compare`
Diffstat (limited to 'plumbing/format/index')
-rw-r--r--plumbing/format/index/decoder.go11
1 files changed, 4 insertions, 7 deletions
diff --git a/plumbing/format/index/decoder.go b/plumbing/format/index/decoder.go
index 5bf6a52..1a58128 100644
--- a/plumbing/format/index/decoder.go
+++ b/plumbing/format/index/decoder.go
@@ -200,11 +200,8 @@ func (d *Decoder) padEntry(idx *Index, e *Entry, read int) error {
entrySize := read + len(e.Name)
padLen := 8 - entrySize%8
- if _, err := io.CopyN(ioutil.Discard, d.r, int64(padLen)); err != nil {
- return err
- }
-
- return nil
+ _, err := io.CopyN(ioutil.Discard, d.r, int64(padLen))
+ return err
}
func (d *Decoder) readExtensions(idx *Index) error {
@@ -288,7 +285,7 @@ func (d *Decoder) readChecksum(expected []byte, alreadyRead [4]byte) error {
return err
}
- if bytes.Compare(h[:], expected) != 0 {
+ if !bytes.Equal(h[:], expected) {
return ErrInvalidChecksum
}
@@ -407,7 +404,7 @@ func (d *resolveUndoDecoder) Decode(ru *ResolveUndo) error {
func (d *resolveUndoDecoder) readEntry() (*ResolveUndoEntry, error) {
e := &ResolveUndoEntry{
- Stages: make(map[Stage]plumbing.Hash, 0),
+ Stages: make(map[Stage]plumbing.Hash),
}
path, err := binary.ReadUntil(d.r, '\x00')