feat(vtag): passthrough fast-path skips Roslyn for mirror scripts (A)
This commit is contained in:
@@ -50,6 +50,18 @@ public sealed class RoslynVirtualTagEvaluator : IVirtualTagEvaluator, IDisposabl
|
||||
if (_disposed) return VirtualTagEvalResult.Failure("evaluator disposed");
|
||||
if (string.IsNullOrWhiteSpace(expression)) return VirtualTagEvalResult.Failure("empty expression");
|
||||
|
||||
// A — passthrough fast-path: the mirror shape `return ctx.GetTag("X").Value;` needs no
|
||||
// Roslyn. Narrow exact pattern; near-misses fall through to the compiled path below.
|
||||
// Semantics are byte-identical to the compiled mirror: a present dependency returns its
|
||||
// value (Ok), and an absent one makes GetTag yield a Bad snapshot whose .Value is null,
|
||||
// so the script returns null — Ok(null) here too.
|
||||
if (PassthroughScript.TryMatch(expression, out var passthroughRef))
|
||||
{
|
||||
return dependencies.TryGetValue(passthroughRef, out var ptValue)
|
||||
? VirtualTagEvalResult.Ok(ptValue)
|
||||
: VirtualTagEvalResult.Ok(null);
|
||||
}
|
||||
|
||||
ScriptEvaluator<VirtualTagContext, object?> evaluator;
|
||||
try
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user