terraform: no need to init state if we don't use

This commit is contained in:
Mitchell Hashimoto 2014-06-05 11:12:10 -07:00
parent e8f235f515
commit 63e1b6f6b7
1 changed files with 4 additions and 7 deletions

View File

@ -143,12 +143,6 @@ func (t *Terraform) diffWalkFn(
state *State, result *Diff) depgraph.WalkFunc { state *State, result *Diff) depgraph.WalkFunc {
var l sync.RWMutex var l sync.RWMutex
// Initialize the state since we always read it
if state == nil {
state = new(State)
state.init()
}
// Initialize the result diff so we can write to it // Initialize the result diff so we can write to it
result.init() result.init()
@ -174,7 +168,10 @@ func (t *Terraform) diffWalkFn(
} }
l.RLock() l.RLock()
rs := state.resources[r.Id()] var rs *ResourceState
if state != nil {
rs = state.resources[r.Id()]
}
if len(vars) > 0 { if len(vars) > 0 {
r = r.ReplaceVariables(vars) r = r.ReplaceVariables(vars)
} }