Skip to content

Optimize Array.prototype.push and pop with dense fast paths #5281#5282

Closed
dhruveshmishra wants to merge 1 commit intoboa-dev:mainfrom
dhruveshmishra:fast-path-array-push-pop
Closed

Optimize Array.prototype.push and pop with dense fast paths #5281#5282
dhruveshmishra wants to merge 1 commit intoboa-dev:mainfrom
dhruveshmishra:fast-path-array-push-pop

Conversation

@dhruveshmishra
Copy link
Copy Markdown

This PR introduces fast-path optimizations for Array.prototype.pop and Array.prototype.push when operating on dense arrays.

Closes #5281

Currently, push and pop operations go through generic property access, which introduces unnecessary overhead. Since most arrays are dense, we can directly operate on underlying storage.

Implementation

  • Added fast path using dense_indexed_properties_mut()
  • Used direct vec.pop() and vec.push() for performance
  • Ensured correctness by checking vec.len() == length
  • Proper borrow handling using drop(obj)
  • Fallback to existing logic for edge cases

Testing

  • All tests pass (cargo test)
  • No regressions observed

Notes

Optimization is applied conservatively to maintain correctness.

@github-actions github-actions bot added the Waiting On Review Waiting on reviews from the maintainers label Mar 29, 2026
@github-actions github-actions bot added this to the v1.0.0 milestone Mar 29, 2026
@github-actions github-actions bot added the C-Builtins PRs and Issues related to builtins/intrinsics label Mar 29, 2026
@jedel1043 jedel1043 closed this Mar 29, 2026
@github-actions github-actions bot removed the Waiting On Review Waiting on reviews from the maintainers label Mar 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-Builtins PRs and Issues related to builtins/intrinsics

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Array.prototype Operations Fast-Path Optimization

2 participants