Skip to content

Some micro tunings / formatting for ModelProxy and Analyzer#11

Merged
Rijicho merged 1 commit into
mainfrom
fix/micro-tuning
Jun 12, 2026
Merged

Some micro tunings / formatting for ModelProxy and Analyzer#11
Rijicho merged 1 commit into
mainfrom
fix/micro-tuning

Conversation

@Rijicho

@Rijicho Rijicho commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Some micro tunings and formatting for ModelProxy and Analyzer.

Related Issue

Changes

Waffle.Analyzer

  • Added a syntax-only pre-filter (HasRenderMethodName) that checks the callee's identifier text before calling SemanticModel.GetSymbolInfo, avoiding expensive semantic lookups on unrelated invocations.
  • Replaced the LINQ chain for finding the interpolated string argument with a foreach loop to avoid unnecessary allocations.
  • Moved the GetSymbolInfo call after both the name pre-filter and the interpolated-string check so the semantic model is only queried when both conditions pass.
  • Replaced _blockStack.Any(f => f.Command.IsIterationBlock) with a dedicated HasIterationFrame() method using a plain foreach, eliminating the LINQ delegate allocation per break/continue check.
  • Added an early-return guard in CheckForOutOfScopeVariables when _closedVariables is empty, skipping all descendant-node traversal and semantic queries until at least one block has been closed.

Waffle.ModelProxy

  • MemberInfo: Introduced a static precomputed s_paramLists array (indexed by parameter count, up to 4) and replaced the string.Join + Enumerable.Range + Select expressions in ParameterizedAccessorBody and ParameterizedHasAccessorBody with direct index lookups.
  • ModelProxyGenerator: Removed a redundant .ToArray() call at the end of a LINQ expression passed to string.Join (the method already accepts IEnumerable).
  • ModelProxyTypeInfoForCache: Replaced this.Equals(Default) in the IsDefault property with a direct OriginalFullName.Length == 0 field check, avoiding record structural equality comparison.
  • SymbolExtensions: Merged two sequential foreach loops over namedType.AllInterfaces into a single pass; IReadOnlyList still short-circuits immediately, and IEnumerable is captured as a fallback via ??=, halving the number of interface iterations in the IEnumerable-only case.

Checklist

  • All existing tests pass (dotnet test -c Debug)
  • New functionality is covered by tests
  • This PR targets the main branch

Contribution License Agreement

@Rijicho Rijicho marked this pull request as ready for review June 12, 2026 08:06
@Rijicho Rijicho merged commit 615d31c into main Jun 12, 2026
4 checks passed
@Rijicho Rijicho deleted the fix/micro-tuning branch June 12, 2026 08:07
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