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(
var err error
valMutationMap := MutationMap{
Initialized: true,
OutOfMutations: false,
LastIncrement: 0,
Constants: []*Constant{},
Mutations: [][]*Value{},
Combination: []*Value{},
DepthIndex: []int{},
OutOfMutations: false,
}
InfoMessage(fmt.Sprintf(
"Initializing Stage %d mutation map for %s...", stage, valPrincipalState.Name,
......@@ -48,8 +49,8 @@ func mutationMapInit(
}
valMutationMap.Combination = make([]*Value, len(valMutationMap.Constants))
valMutationMap.DepthIndex = make([]int, len(valMutationMap.Constants))
for iiii := range valMutationMap.Constants {
valMutationMap.DepthIndex[iiii] = 0
for ii := 0; ii < len(valMutationMap.Constants); ii++ {
valMutationMap.DepthIndex[ii] = 0
}
return valMutationMap, err
}
......
......@@ -51,13 +51,14 @@ func verifyActiveStages(
stage int, valKnowledgeMap *KnowledgeMap, valPrincipalStates []*PrincipalState,
valAttackerState AttackerState, stageGroup *sync.WaitGroup,
) {
var scanGroup sync.WaitGroup
var principalGroup sync.WaitGroup
var err error
oldKnown := len(valAttackerState.Known)
valAttackerState = attackerStateGetRead()
scanGroup.Add(len(valPrincipalStates))
principalGroup.Add(len(valPrincipalStates))
for _, valPrincipalState := range valPrincipalStates {
go func(valPrincipalState *PrincipalState) {
var scanGroup sync.WaitGroup
var valMutationMap MutationMap
valMutationMap, err = mutationMapInit(
valKnowledgeMap, valPrincipalState, valAttackerState, stage,
......@@ -75,10 +76,11 @@ func verifyActiveStages(
scanGroup.Done()
return
}
scanGroup.Done()
scanGroup.Wait()
principalGroup.Done()
}(valPrincipalState)
}
scanGroup.Wait()
principalGroup.Wait()
exhausted := (stage > 5 && (oldKnown == len(valAttackerState.Known)))
if exhausted {
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