From 18e6f9daa3899318d36b525b068837f49bc2c1cf Mon Sep 17 00:00:00 2001 From: ferhat elmas Date: Wed, 29 Nov 2017 02:24:31 +0100 Subject: 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` --- plumbing/format/config/encoder.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'plumbing/format/config/encoder.go') diff --git a/plumbing/format/config/encoder.go b/plumbing/format/config/encoder.go index 6d17a5a..4eac896 100644 --- a/plumbing/format/config/encoder.go +++ b/plumbing/format/config/encoder.go @@ -53,17 +53,13 @@ func (e *Encoder) encodeSubsection(sectionName string, s *Subsection) error { return err } - if err := e.encodeOptions(s.Options); err != nil { - return err - } - - return nil + return e.encodeOptions(s.Options) } func (e *Encoder) encodeOptions(opts Options) error { for _, o := range opts { pattern := "\t%s = %s\n" - if strings.Index(o.Value, "\\") != -1 { + if strings.Contains(o.Value, "\\") { pattern = "\t%s = %q\n" } -- cgit