Skip to content

Commit

Permalink
Simplify hash functions in servers and quotas
Browse files Browse the repository at this point in the history
Use simple fmt.Sprintf instead of working with buffers in the
"hashQuotas" and "hashServers" functions.
  • Loading branch information
ozerovandrei committed Nov 7, 2018
1 parent a73aaf0 commit ffaa12f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
4 changes: 1 addition & 3 deletions selvpc/resource_selvpc_resell_project_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -432,10 +432,8 @@ func resourceQuotasHashSetFunc() schema.SchemaSetFunc {

// hashQuotas is a hash function to use with the "quotas" and "all_quotas" sets.
func hashQuotas(v interface{}) int {
var buf bytes.Buffer
m := v.(map[string]interface{})
buf.WriteString(fmt.Sprintf("%s-", m["resource_name"].(string)))
return hashcode.String(buf.String())
return hashcode.String(fmt.Sprintf("%s-", m["resource_name"].(string)))
}

// hashResourceQuotas is a hash function to use with the "resource_quotas" set.
Expand Down
5 changes: 1 addition & 4 deletions selvpc/servers.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package selvpc

import (
"bytes"
"fmt"

"github.com/hashicorp/terraform/helper/hashcode"
Expand All @@ -28,8 +27,6 @@ func serversMapsFromStructs(serverStructs []servers.Server) []map[string]interfa

// hashServers is a hash function to use with the "servers" set.
func hashServers(v interface{}) int {
var buf bytes.Buffer
m := v.(map[string]interface{})
buf.WriteString(fmt.Sprintf("%s-", m["id"].(string)))
return hashcode.String(buf.String())
return hashcode.String(fmt.Sprintf("%s-", m["id"].(string)))
}

0 comments on commit ffaa12f

Please sign in to comment.