Verified Commit 0faa6317 authored by Nadim Kobeissi's avatar Nadim Kobeissi 💾
Browse files

Minor optimizations

parent e947a1c5
Pipeline #824 passed with stages
in 2 minutes and 25 seconds
...@@ -15,11 +15,12 @@ func mutationMapInit( ...@@ -15,11 +15,12 @@ func mutationMapInit(
var err error var err error
valMutationMap := MutationMap{ valMutationMap := MutationMap{
Initialized: true, Initialized: true,
OutOfMutations: false,
LastIncrement: 0,
Constants: []*Constant{}, Constants: []*Constant{},
Mutations: [][]*Value{}, Mutations: [][]*Value{},
Combination: []*Value{}, Combination: []*Value{},
DepthIndex: []int{}, DepthIndex: []int{},
OutOfMutations: false,
} }
InfoMessage(fmt.Sprintf( InfoMessage(fmt.Sprintf(
"Initializing Stage %d mutation map for %s...", stage, valPrincipalState.Name, "Initializing Stage %d mutation map for %s...", stage, valPrincipalState.Name,
...@@ -48,8 +49,8 @@ func mutationMapInit( ...@@ -48,8 +49,8 @@ func mutationMapInit(
} }
valMutationMap.Combination = make([]*Value, len(valMutationMap.Constants)) valMutationMap.Combination = make([]*Value, len(valMutationMap.Constants))
valMutationMap.DepthIndex = make([]int, len(valMutationMap.Constants)) valMutationMap.DepthIndex = make([]int, len(valMutationMap.Constants))
for iiii := range valMutationMap.Constants { for ii := 0; ii < len(valMutationMap.Constants); ii++ {
valMutationMap.DepthIndex[iiii] = 0 valMutationMap.DepthIndex[ii] = 0
} }
return valMutationMap, err return valMutationMap, err
} }
......
...@@ -51,13 +51,14 @@ func verifyActiveStages( ...@@ -51,13 +51,14 @@ func verifyActiveStages(
stage int, valKnowledgeMap *KnowledgeMap, valPrincipalStates []*PrincipalState, stage int, valKnowledgeMap *KnowledgeMap, valPrincipalStates []*PrincipalState,
valAttackerState AttackerState, stageGroup *sync.WaitGroup, valAttackerState AttackerState, stageGroup *sync.WaitGroup,
) { ) {
var scanGroup sync.WaitGroup var principalGroup sync.WaitGroup
var err error var err error
oldKnown := len(valAttackerState.Known) oldKnown := len(valAttackerState.Known)
valAttackerState = attackerStateGetRead() valAttackerState = attackerStateGetRead()
scanGroup.Add(len(valPrincipalStates)) principalGroup.Add(len(valPrincipalStates))
for _, valPrincipalState := range valPrincipalStates { for _, valPrincipalState := range valPrincipalStates {
go func(valPrincipalState *PrincipalState) { go func(valPrincipalState *PrincipalState) {
var scanGroup sync.WaitGroup
var valMutationMap MutationMap var valMutationMap MutationMap
valMutationMap, err = mutationMapInit( valMutationMap, err = mutationMapInit(
valKnowledgeMap, valPrincipalState, valAttackerState, stage, valKnowledgeMap, valPrincipalState, valAttackerState, stage,
...@@ -75,10 +76,11 @@ func verifyActiveStages( ...@@ -75,10 +76,11 @@ func verifyActiveStages(
scanGroup.Done() scanGroup.Done()
return return
} }
scanGroup.Done() scanGroup.Wait()
principalGroup.Done()
}(valPrincipalState) }(valPrincipalState)
} }
scanGroup.Wait() principalGroup.Wait()
exhausted := (stage > 5 && (oldKnown == len(valAttackerState.Known))) exhausted := (stage > 5 && (oldKnown == len(valAttackerState.Known)))
if exhausted { if exhausted {
attackerStatePutExhausted() attackerStatePutExhausted()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment