Skip to content

Simplify gradient calc#4

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

Simplify gradient calc#4
kelindar merged 1 commit intomainfrom
grad2

Conversation

@kelindar
Copy link
Copy Markdown
Owner

This pull request refactors parts of the simplex.go implementation to simplify indexing logic and remove unused code, resulting in a cleaner and slightly more efficient codebase. The main changes include updating index types and access patterns in the noise generation function, removing the unused dot2D function, and deleting its associated benchmark.

Refactoring and simplification of indexing logic:

  • Updated index types and access patterns in Noise2 to use uint8 for indices and direct indexing for perm and grad, replacing slice windows and type conversions for improved clarity and performance. (simplex.go, simplex.goL85-R92)
  • Changed the declaration of table from a slice to an array for better type safety. (simplex.go, simplex.goL13-R13)

Code cleanup:

  • Removed the unused dot2D function, eliminating dead code from the codebase. (simplex.go, simplex.goL118-R114)
  • Deleted the BenchmarkDot benchmark and its related comments, as it is no longer relevant after removing dot2D. (simplex_test.go, simplex_test.goL42-L61)

Minor math simplification:

  • Simplified the pow4 function by removing redundant lines and returning the result directly. (simplex.go, simplex.goL118-R114)

@kelindar kelindar merged commit f245281 into main Aug 10, 2025
4 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