Skip to content
Merged
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
9 changes: 4 additions & 5 deletions fen.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@ func decodeFEN(fen string) (*Position, error) {
}, nil
}

// preallocated array to avoid strings.Split allocation
//
//nolint:gochecknoglobals // this is a preallocated array.
var rankBuffer [8]string

const (
fileMapSize = 8
pieceMapSize = 32
Expand Down Expand Up @@ -95,6 +90,10 @@ func clearMap[K comparable, V any](m map[K]V) {
func fenBoard(boardStr string) (*Board, error) {
const maxRankLen = 8

// Local preallocated array to avoid strings.Split allocations.
// Kept local (instead of global) so fenBoard is concurrency-safe.
var rankBuffer [maxRankLen]string

// Get maps from pools
m, _ := pieceMapPool.Get().(map[Square]Piece)
fileMap, _ := fileMapPool.Get().(map[File]Piece)
Expand Down
Loading