[Repo Assist] perf/refactor: unify canBind* helpers; skip Array.filter on bindAll path#509
Draft
github-actions[bot] wants to merge 2 commits intomasterfrom
Draft
Conversation
…ath in TargetTypeDefinition and TypeSymbol - Extract canBindByVisibility inline helper shared by all five canBind* functions (canBindConstructor / canBindMethod / canBindProperty / canBindField / canBindEvent), removing five nearly-identical bodies. - Add isVisibilityBindAll helper: returns true when both Public and NonPublic BindingFlags are set, meaning every member passes the visibility filter. - Use isVisibilityBindAll in TargetTypeDefinition.GetConstructors/GetMethods/ GetFields/GetEvents/GetProperties/GetNestedTypes: return the already-computed lazy array directly instead of calling Array.filter and allocating a fresh copy. The F# compiler always calls these with bindAll (Public|NonPublic|Static|Instance| DeclaredOnly), so this eliminates a redundant O(n) allocation on every member enumeration of every TargetTypeDefinition. - Apply the same short-circuit in TypeSymbol.Get* for TargetGeneric instantiations. 157/157 tests pass. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This is an automated PR from Repo Assist.
Summary
Two closely-related improvements to
ProvidedTypes.fs(Tasks 8 & 5):Task 5 — Coding improvement: unify
canBind*helpersThe five visibility-filter helpers (
canBindConstructor,canBindMethod,canBindProperty,canBindField,canBindEvent) had identical bodies:These are now expressed via a shared
canBindByVisibilityinline helper, reducing duplication and making the pattern more explicit.Task 8 — Performance improvement: skip
Array.filteron thebindAllpathIn
TargetTypeDefinition.GetMethods(bindingFlags)(andGetConstructors,GetFields,GetEvents,GetProperties,GetNestedTypes), every call previously did:methDefs.Force()is cached (Lazy), butArray.filterallocates a new array on every call. When bothPublicandNonPublicare inbindingFlagsevery member passes the filter — the allocation is wasted.The new
isVisibilityBindAllhelper detects this case and returns the cached array directly:All 157 tests pass with no changes to test code.