Skip to content

Don't allocate empty IInvocation.Arguments arrays#738

Merged
stakx merged 1 commit intocastleproject:masterfrom
stakx:no-empty-arguments-alloc
Feb 8, 2026
Merged

Don't allocate empty IInvocation.Arguments arrays#738
stakx merged 1 commit intocastleproject:masterfrom
stakx:no-empty-arguments-alloc

Conversation

@stakx
Copy link
Member

@stakx stakx commented Feb 8, 2026

This is a small and straightforward runtime memory optimization: for parameter-less intercepted methods, reuse Array.Empty<object?>() as the backing array for IInvocation.Arguments instead of allocating a new object?[0] on every invocation.

@stakx stakx added this to the vNext milestone Feb 8, 2026
@stakx stakx self-assigned this Feb 8, 2026
@stakx stakx merged commit 77cb103 into castleproject:master Feb 8, 2026
4 checks passed
@stakx stakx deleted the no-empty-arguments-alloc branch February 8, 2026 23:21
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.

1 participant