Skip to content

Commit

Permalink
matching: ellipsis: Always try going deep
Browse files Browse the repository at this point in the history
TODO: Test performance

Follows: c1ca429 ("Optimize deep statement matching (#852)")

test plan:
TODO
  • Loading branch information
IagoAbal committed Aug 10, 2023
1 parent 176cfc3 commit d194e4b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions src/matching/Generic_vs_generic.ml
Expand Up @@ -2238,14 +2238,14 @@ and m_stmts_deep ~inside ~less_is_ok (xsa : G.stmt list) (xsb : G.stmt list) =
| ( ({ s = G.ExprStmt ({ e = G.Ellipsis _i; _ }, _); _ } :: _ as xsa),
(_ :: _ as xsb) ) ->
(* let's first try without going deep *)
m_list__m_stmt xsa xsb >!> fun () ->
if_config
(fun x -> x.go_deeper_stmt)
~then_:
(match SubAST_generic.flatten_substmts_of_stmts xsb with
| None -> fail () (* was already flat *)
| Some (xsb, _UNUSED_last_stmt) -> m_list__m_stmt xsa xsb)
~else_:(fail ())
m_list__m_stmt xsa xsb
>||> if_config
(fun x -> x.go_deeper_stmt)
~then_:
(match SubAST_generic.flatten_substmts_of_stmts xsb with
| None -> fail () (* was already flat *)
| Some (xsb, _UNUSED_last_stmt) -> m_list__m_stmt xsa xsb)
~else_:(fail ())
(* dots: metavars: $...BODY *)
| ( ({ s = G.ExprStmt ({ e = G.N (G.Id ((s, _), _idinfo)); _ }, _); _ } :: _
as xsa),
Expand Down
2 changes: 1 addition & 1 deletion tests/semgrep-rules

0 comments on commit d194e4b

Please sign in to comment.