From 63e1b6f6b7fa7e5160040f168201ef32d7b1d12f Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 5 Jun 2014 11:12:10 -0700 Subject: [PATCH] terraform: no need to init state if we don't use --- terraform/terraform.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/terraform/terraform.go b/terraform/terraform.go index 83a0360c5..5b1ecf35f 100644 --- a/terraform/terraform.go +++ b/terraform/terraform.go @@ -143,12 +143,6 @@ func (t *Terraform) diffWalkFn( state *State, result *Diff) depgraph.WalkFunc { 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 result.init() @@ -174,7 +168,10 @@ func (t *Terraform) diffWalkFn( } l.RLock() - rs := state.resources[r.Id()] + var rs *ResourceState + if state != nil { + rs = state.resources[r.Id()] + } if len(vars) > 0 { r = r.ReplaceVariables(vars) }