Skip to content

parser: look up the string.Concat overloads once - #45

Merged
rameel merged 1 commit into
mainfrom
parser/cache-concat-overloads
Nov 19, 2026
Merged

rameel merged 1 commit into
mainfrom
parser/cache-concat-overloads

Conversation

@rameel

@rameel rameel commented Nov 19, 2026

Copy link
Copy Markdown
Owner

Each + with a string operand looked up the string.Concat overloads through reflection again: typeof(string).GetMethods followed by filtering. The lookup allocated about 3.3 KB per operator, while the whole Parse("\"a\" + 1") now allocates 2.8 KB.

This PR looks up the overloads once and stores them in a static field. MethodResolver.ResolveMethod copies the list before reordering the candidates, so sharing the array is safe. The selected overloads are unchanged.

Each + with a string operand called typeof(string).GetMethods and
filtered the result again, allocating about 3.3 KB per operator.
Store the overloads in a static field instead.
@rameel
rameel merged commit 17835a3 into main Nov 19, 2026
1 check passed
@rameel
rameel deleted the parser/cache-concat-overloads branch November 19, 2026 19:42
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