Skip to content

Removed unsafe#2

Merged
kelindar merged 1 commit intomainfrom
unsafe
Aug 10, 2025
Merged

Removed unsafe#2
kelindar merged 1 commit intomainfrom
unsafe

Conversation

@kelindar
Copy link
Owner

This pull request refactors the simplex.go implementation to remove unsafe pointer usage, replacing it with safer, direct indexing into arrays. Additionally, it simplifies the benchmarking logic in bench/main.go by fixing the input size for noise tests. These changes improve code safety, readability, and maintainability.

Simplex noise implementation refactor

  • Removed all use of unsafe.Pointer and related pointer arithmetic in simplex.go, eliminating the pPerm and pGrad variables and associated functions (permutationsAt and gradientAt). All array accesses are now done via safe indexing. [1] [2] [3]
  • Updated the Noise2 function to use direct array indexing for permutation and gradient lookup, with explicit bounds checks for the compiler.

Benchmark logic simplification

  • Changed the benchmarking loop in bench/main.go to use a fixed input size (size = 1000) for all shapes, instead of iterating over multiple sizes.
  • Minor cleanup in bench/main.go by removing an unnecessary closing brace.

@kelindar kelindar merged commit 7fa9fe1 into main Aug 10, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant