The GitHub Actions job "CI" on tvm-ffi.git/main has succeeded.
Run started by GitHub user tqchen (triggered by tqchen).

Head commit for run:
a7eafccdf2f75df35d0e7819cad7c975d63f4091 / Shushi Hong <[email protected]>
[Perf][Rust] Optimize match_any! ordered conversion and exact-leaf dispatch 
(#692)

This PR improves both Rust `match_any!` dispatch paths without changing
how matching works.

## Ordered dispatch

When an arm does not match, the internal conversion now returns
`Err(())` instead of creating a `TypeError`. This makes failed checks
cheaper while keeping the public `TryFrom<AnyView>` API unchanged.

Custom `TryInto` matchers are still supported and continue to run in
source order.

## Exact-leaf dispatch

For a match with many exact final object types, the macro builds one
`TypeIndex → ArmId` table through `OnceLock`.

The table uses the smallest pattern `TypeIndex` as its starting point:

```text
base = minimum pattern TypeIndex
arm_ids[pattern_type_index - base] = source ArmId
```

Each call then selects an arm directly with:

```text
arm_ids[runtime_type_index - base]
```

This is an O(1) lookup. Only the selected object handle is created, and
its type check is not repeated.

The direct table is used when there are at least 20 typed arms, every
pattern matches one exact final runtime type, there are no guards, and
bindings are simple names or `_`. Smaller matches, guarded arms,
parent-type patterns, parameterized containers, and custom matchers
continue using ordered dispatch.

The input value is still evaluated once. Duplicate types still select
the first arm, and unmatched or non-object values still use the final
`_` fallback. A `TypeId` check prevents the same static table from being
incorrectly shared by different generic pattern lists.

Report URL: https://github.com/apache/tvm-ffi/actions/runs/30595265163

With regards,
GitHub Actions via GitBox


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to