Skip to content

Conversation

@samdark
Copy link
Member

@samdark samdark commented Jul 25, 2025

Q A
Is bugfix?
New feature?
Breaks BC?

@samdark samdark requested review from Copilot and vjik July 25, 2025 06:22
Copy link

Copilot AI left a comment

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 optimizes the getValue method in ArrayHelper by adding a fast path for simple array access operations. The optimization inlines the common case of retrieving a value from an array using a string or integer key, avoiding the overhead of calling the more complex getRootValue method when dealing with simple key access patterns.

Key changes:

  • Adds an early return condition for simple array access using string or integer keys
  • Uses array_key_exists for existence check followed by direct array access

@samdark
Copy link
Member Author

samdark commented Jul 25, 2025

Need to compare results one more time.

Co-authored-by: Aleksei Gagarin <roxblnfk@ya.ru>
return $key($array, $default);
}

if (is_array($array) && is_scalar($key)) {
Copy link
Member

Choose a reason for hiding this comment

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

use common is_array($array) check with the following condition instead

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.

3 participants