aboutsummaryrefslogtreecommitdiffstats
path: root/config
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 /config
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 'config')
-rw-r--r--config/config.go11
-rw-r--r--config/modules.go2
-rw-r--r--config/refspec.go14
3 files changed, 7 insertions, 20 deletions
diff --git a/config/config.go b/config/config.go
index 477eb35..fc4cd28 100644
--- a/config/config.go
+++ b/config/config.go
@@ -65,8 +65,8 @@ type Config struct {
// NewConfig returns a new empty Config.
func NewConfig() *Config {
return &Config{
- Remotes: make(map[string]*RemoteConfig, 0),
- Submodules: make(map[string]*Submodule, 0),
+ Remotes: make(map[string]*RemoteConfig),
+ Submodules: make(map[string]*Submodule),
Raw: format.New(),
}
}
@@ -290,13 +290,8 @@ func (c *RemoteConfig) unmarshal(s *format.Subsection) error {
fetch = append(fetch, rs)
}
- var urls []string
- for _, f := range c.raw.Options.GetAll(urlKey) {
- urls = append(urls, f)
- }
-
c.Name = c.raw.Name
- c.URLs = urls
+ c.URLs = append([]string(nil), c.raw.Options.GetAll(urlKey)...)
c.Fetch = fetch
return nil
diff --git a/config/modules.go b/config/modules.go
index 24ef304..b208984 100644
--- a/config/modules.go
+++ b/config/modules.go
@@ -24,7 +24,7 @@ type Modules struct {
// NewModules returns a new empty Modules
func NewModules() *Modules {
return &Modules{
- Submodules: make(map[string]*Submodule, 0),
+ Submodules: make(map[string]*Submodule),
raw: format.New(),
}
}
diff --git a/config/refspec.go b/config/refspec.go
index 7e4106a..af7e732 100644
--- a/config/refspec.go
+++ b/config/refspec.go
@@ -51,20 +51,12 @@ func (s RefSpec) Validate() error {
// IsForceUpdate returns if update is allowed in non fast-forward merges.
func (s RefSpec) IsForceUpdate() bool {
- if s[0] == refSpecForce[0] {
- return true
- }
-
- return false
+ return s[0] == refSpecForce[0]
}
// IsDelete returns true if the refspec indicates a delete (empty src).
func (s RefSpec) IsDelete() bool {
- if s[0] == refSpecSeparator[0] {
- return true
- }
-
- return false
+ return s[0] == refSpecSeparator[0]
}
// Src return the src side.
@@ -87,7 +79,7 @@ func (s RefSpec) Match(n plumbing.ReferenceName) bool {
// IsWildcard returns true if the RefSpec contains a wildcard.
func (s RefSpec) IsWildcard() bool {
- return strings.Index(string(s), refSpecWildcard) != -1
+ return strings.Contains(string(s), refSpecWildcard)
}
func (s RefSpec) matchExact(n plumbing.ReferenceName) bool {