Skip to content

Conversation

@dereuromark
Copy link
Contributor

Summary

  • Replace array_values($arr) !== $arr with native array_is_list() function
  • The old approach created a full copy of the array just to check if it was sequential

Performance Impact

Expected ~5-10% improvement for large nested collections.

Changes

  • Updated 3 occurrences in collection creation methods
  • Uses PHP 8.1+ native function (already required by composer.json: PHP ^8.2)

Replace the O(n) memory comparison `array_values($arr) !== $arr` with
the native `array_is_list()` function available in PHP 8.1+.

The old approach created a full copy of the array just to check if it
was a sequential list vs. an associative array. The native function
is significantly more efficient.

Performance improvement: ~5-10% for large nested collections.
@codecov
Copy link

codecov bot commented Jan 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.71%. Comparing base (7616455) to head (0b91f24).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##             master      #58   +/-   ##
=========================================
  Coverage     82.71%   82.71%           
  Complexity     1205     1205           
=========================================
  Files            36       36           
  Lines          2951     2951           
=========================================
  Hits           2441     2441           
  Misses          510      510           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dereuromark dereuromark merged commit f30256c into master Jan 22, 2026
12 checks passed
@dereuromark dereuromark deleted the optimize-array-is-list branch January 22, 2026 04:57
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.

2 participants