Skip to content

⚡️ avoid useless json_encode - #87

Merged
garak merged 1 commit into
p-chess:masterfrom
garak:fix-cache-key
Jul 3, 2026
Merged

⚡️ avoid useless json_encode#87
garak merged 1 commit into
p-chess:masterfrom
garak:fix-cache-key

Conversation

@garak

@garak garak commented Jul 2, 2026

Copy link
Copy Markdown
Member

Fix #85

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses Issue #85 by simplifying the cache-key generation in Chess::generateMoves() to avoid unnecessary json_encode() on a simple derived string, while preserving cache behavior within the generateMovesCache map.

Changes:

  • Replace json_encode($square . (legal-flag), JSON_THROW_ON_ERROR) with direct string concatenation for the cache key in generateMoves().
  • Remove an avoidable JSON encoding call in a hot path (move generation), reducing overhead.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@garak
garak merged commit a401c88 into p-chess:master Jul 3, 2026
5 checks passed
@garak
garak deleted the fix-cache-key branch July 3, 2026 07:24
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.

Improve cache key in generateMoves()

2 participants