Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions internal/literals/obfuscators.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func randExtKey(rand *mathrand.Rand, idx int) *externalKey {
func randExtKeys(rand *mathrand.Rand) []*externalKey {
count := minExtKeyCount + rand.Intn(maxExtKeyCount-minExtKeyCount)
keys := make([]*externalKey, count)
for i := 0; i < count; i++ {
for i := range count {
keys[i] = randExtKey(rand, i)
}
return keys
Expand Down Expand Up @@ -211,7 +211,7 @@ func dataToByteSliceWithExtKeys(rand *mathrand.Rand, data []byte, extKeys []*ext
extKeyOpCount := minByteSliceExtKeyOps + rand.Intn(maxByteSliceExtKeyOps-minByteSliceExtKeyOps)

var stmts []ast.Stmt
for i := 0; i < extKeyOpCount; i++ {
for range extKeyOpCount {
key := extKeys[rand.Intn(len(extKeys))]
key.AddRef()

Expand Down
9 changes: 3 additions & 6 deletions internal/literals/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ type proxyDispatcher struct {

func (d *proxyDispatcher) initialize() {
flattenStructs := make([]*proxyStruct, d.rand.Intn(maxStructCount-minStructCount)+minStructCount)
for i := 0; i < len(flattenStructs); i++ {
for i := range flattenStructs {
flattenStructs[i] = &proxyStruct{
typeName: d.nameFunc(d.rand, "proxyStructName"+strconv.Itoa(i)),
name: d.nameFunc(d.rand, "proxyStructFieldName"+strconv.Itoa(i)),
Expand All @@ -75,10 +75,7 @@ func (d *proxyDispatcher) initialize() {
current := queue[0]
queue = queue[1:]

childCount := d.rand.Intn(maxChildCount-minChildCount) + minChildCount
if childCount > len(unassigned) {
childCount = len(unassigned)
}
childCount := min(d.rand.Intn(maxChildCount-minChildCount)+minChildCount, len(unassigned))

for i := 0; i < childCount; i++ {
child := unassigned[0]
Expand Down Expand Up @@ -194,7 +191,7 @@ func (d *proxyDispatcher) AddToFile(file *ast.File) {

for _, strct := range d.flattenStructs {
dummyCount := d.rand.Intn(maxJunkValueCount-minJunkValueCount+1) + minJunkValueCount
for i := 0; i < dummyCount; i++ {
for range dummyCount {
strct.values = append(strct.values, d.junkValue())
}

Expand Down
Loading