Skip to content

Commit

Permalink
Fixing linter errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
cokicm committed Mar 19, 2024
1 parent 9fe63c8 commit 389282a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 6 additions & 2 deletions state/runtime/evm/instructions_benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ func GetLarge256bitUint() uint256.Int {
}

func TestGenericWriteToSlice32(t *testing.T) {

expectedDestinationSlice := [32]uint8{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31}

var destination [32]byte
Expand All @@ -257,7 +256,6 @@ func TestGenericWriteToSlice32(t *testing.T) {
}

func TestGenericWriteToSlice(t *testing.T) {

expectedDestinationSlice := [32]uint8{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31}

var destination [32]byte
Expand All @@ -271,29 +269,35 @@ func TestGenericWriteToSlice(t *testing.T) {

func BenchmarkUint256WriteToSlice(b *testing.B) {
value := GetLarge256bitUint()

var destination [32]byte

b.ResetTimer()

for i := 0; i < b.N; i++ {
value.WriteToSlice(destination[:])
}
}

func BenchmarkStaticUnrolledWriteToSlice(b *testing.B) {
value := GetLarge256bitUint()

var destination [32]byte

b.ResetTimer()

for i := 0; i < b.N; i++ {
WriteToSlice32(value, destination[:])
}
}

func BenchmarkGenericStaticUnrolledWriteToSlice(b *testing.B) {
value := GetLarge256bitUint()

var destination [32]byte

b.ResetTimer()

for i := 0; i < b.N; i++ {
WriteToSlice(value, destination[:])
}
Expand Down
3 changes: 0 additions & 3 deletions state/runtime/evm/optimized_stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
// to keep track of the current stack pointer.
// OptimizedStack uint256 integers for improved operations on values on the
// stack and minimizes heap allocations.
// TODO: Check if sp field can be removed.
type OptimizedStack struct {
sp int // Stack pointer to track the top of the stack
data []uint256.Int // Slice to store the stack's elements
Expand Down Expand Up @@ -61,14 +60,12 @@ func (s *OptimizedStack) top() (*uint256.Int, error) {
// peekAt returns the element at the nth position from the top of the stack,
// without modifying the stack. It does not perform bounds checking and it
// returns the value of the element, not the reference.
// TODO: Check on error handling
func (s *OptimizedStack) peekAt(n int) uint256.Int {
return s.data[s.sp-n]
}

// swap exchanges the top element of the stack with the element at the n-th position
// from the top. It does not perform bounds checking and assumes valid input.
// TODO: Check on error handling
func (s *OptimizedStack) swap(n int) {
s.data[s.sp-1], s.data[s.sp-n-1] = s.data[s.sp-n-1], s.data[s.sp-1]
}

0 comments on commit 389282a

Please sign in to comment.