# UNDF: UNDF-2026-000000375
# dart-0003: SSA builder namedParameters.contains() in argument ordering — O(N²)

## Severity
MEDIUM

## Location
`pkg/compiler/lib/src/ssa/builder.dart`
Line 5007 (argument ordering logic in call-site code generation)

## Description
During call-site code generation the SSA builder sorts named arguments into
parameter-position order. It filters the target function's declared named
parameters using:

```dart
target.namedParameters
    .where((p) => parameterStructure.namedParameters.contains(p.name))
```

`parameterStructure.namedParameters` is `List<String>`. The `.where()` predicate
is called once per item in `target.namedParameters`, and each predicate call does
a full O(N) linear scan of the `List<String>`. Total cost: O(N²).

## Defective Code

```dart
// pkg/compiler/lib/src/ssa/builder.dart:5000–5011
List<ir.VariableDeclaration> namedParameters =
    target.namedParameters
        // Filter elided parameters.
        .where((p) => parameterStructure.namedParameters.contains(p.name))  // O(N) per call
        .toList()
      ..sort(namedOrdering);
```

## Fix

```dart
// FIXED
final Set<String> liveNames =
    parameterStructure.namedParameters.toSet();          // O(N) once
List<ir.VariableDeclaration> namedParameters =
    target.namedParameters
        .where((p) => liveNames.contains(p.name))        // O(1) per call
        .toList()
      ..sort(namedOrdering);
```

## Complexity
| | Before | After |
|---|--------|-------|
| Per call site | O(N²) | O(N) |

## Related
- dart-0001: same root cause in `element_map.dart`
- dart-0002: same pattern at `builder.dart:2156`
