preallocate data in shuffle and split literal obfuscator

pull/648/head
pagran 2 years ago committed by lu4p
parent 5b2193351f
commit e04c605c93

@ -52,14 +52,10 @@ func (shuffle) obfuscate(obfRand *mathrand.Rand, data []byte) *ast.BlockStmt {
Tok: token.DEFINE, Tok: token.DEFINE,
Rhs: []ast.Expr{ah.DataToByteSlice(shuffledFullData)}, Rhs: []ast.Expr{ah.DataToByteSlice(shuffledFullData)},
}, },
&ast.DeclStmt{ &ast.AssignStmt{
Decl: &ast.GenDecl{ Lhs: []ast.Expr{ast.NewIdent("data")},
Tok: token.VAR, Tok: token.DEFINE,
Specs: []ast.Spec{&ast.ValueSpec{ Rhs: []ast.Expr{ah.CallExpr(ast.NewIdent("make"), &ast.ArrayType{Elt: ast.NewIdent("byte")}, ah.IntLit(0), ah.IntLit(len(data)+1))},
Names: []*ast.Ident{ast.NewIdent("data")},
Type: &ast.ArrayType{Elt: ast.NewIdent("byte")},
}},
},
}, },
&ast.AssignStmt{ &ast.AssignStmt{
Lhs: []ast.Expr{ast.NewIdent("data")}, Lhs: []ast.Expr{ast.NewIdent("data")},

@ -158,15 +158,11 @@ func (split) obfuscate(obfRand *mathrand.Rand, data []byte) *ast.BlockStmt {
} }
return ah.BlockStmt( return ah.BlockStmt(
&ast.DeclStmt{Decl: &ast.GenDecl{ &ast.AssignStmt{
Tok: token.VAR, Lhs: []ast.Expr{ast.NewIdent("data")},
Specs: []ast.Spec{ Tok: token.DEFINE,
&ast.ValueSpec{ Rhs: []ast.Expr{ah.CallExpr(ast.NewIdent("make"), &ast.ArrayType{Elt: ast.NewIdent("byte")}, ah.IntLit(0), ah.IntLit(len(data)+1))},
Names: []*ast.Ident{ast.NewIdent("data")}, },
Type: &ast.ArrayType{Elt: ast.NewIdent("byte")},
},
},
}},
&ast.AssignStmt{ &ast.AssignStmt{
Lhs: []ast.Expr{ast.NewIdent("i")}, Lhs: []ast.Expr{ast.NewIdent("i")},
Tok: token.DEFINE, Tok: token.DEFINE,

Loading…
Cancel
Save