mirror of
https://github.com/Z3Prover/z3
synced 2026-06-19 23:26:30 +00:00
ZIPT review identified two hot-path inefficiencies in `euf_sgraph`:
`drop_left`/`drop_right` were implemented as repeated single-token drops
(`O(count × depth)`), and `classify` performed redundant string checks.
This change aligns behavior with the intended tree-navigation approach
while keeping semantics unchanged.
- **Algorithmic update: `drop_left` / `drop_right`**
- Replaced iterative `drop_first`/`drop_last` loops with direct
recursion over concat children.
- New logic drops across subtree boundaries using child lengths,
reducing work to tree depth (`O(depth)`).
- **Classification cleanup: `classify`**
- Collapsed double `is_string` probing into a single `is_string(e, s)`
call.
- Preserves existing kind mapping (`empty` vs non-empty string constant
handling).
- **Focused test coverage extension**
- Added boundary checks in `test_sgraph_drop` for `drop_left(..., 1)`
and `drop_right(..., 1)` on a 4-token concat tree.
```cpp
snode* sgraph::drop_left(snode* n, unsigned count) {
if (count == 0 || n->is_empty()) return n;
if (count >= n->length()) return mk_empty_seq(n->get_sort());
SASSERT(n->is_concat());
unsigned left_len = n->arg(0)->length();
if (count < left_len)
return mk_concat(drop_left(n->arg(0), count), n->arg(1));
return drop_left(n->arg(1), count - left_len);
}
```
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
|
||
|---|---|---|
| .. | ||
| CMakeLists.txt | ||
| euf_ac_plugin.cpp | ||
| euf_ac_plugin.h | ||
| euf_arith_plugin.cpp | ||
| euf_arith_plugin.h | ||
| euf_bv_plugin.cpp | ||
| euf_bv_plugin.h | ||
| euf_egraph.cpp | ||
| euf_egraph.h | ||
| euf_enode.cpp | ||
| euf_enode.h | ||
| euf_etable.cpp | ||
| euf_etable.h | ||
| euf_justification.cpp | ||
| euf_justification.h | ||
| euf_mam.cpp | ||
| euf_mam.h | ||
| euf_plugin.cpp | ||
| euf_plugin.h | ||
| euf_seq_plugin.cpp | ||
| euf_seq_plugin.h | ||
| euf_sgraph.cpp | ||
| euf_sgraph.h | ||
| euf_snode.h | ||
| euf_specrel_plugin.cpp | ||
| euf_specrel_plugin.h | ||
| ho_matcher.cpp | ||
| ho_matcher.h | ||