Avoid cloning blocks in emit_statement.rs
commit9d4977e17e484a8762075afbdfda45461b034f02
authorMillie Chen <milliechen@fb.com>
Wed, 4 Mar 2020 23:10:00 +0000 (4 15:10 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Wed, 4 Mar 2020 23:22:29 +0000 (4 15:22 -0800)
tree213ce6d41c20524d8c2e725d902bdd5c3316bca9
parent70f0a5637e09eec5fc2d9db33189b7127afd2996
Avoid cloning blocks in emit_statement.rs

Summary: When emitting the body block in for, foreach, while, and do loops, the OCaml version wraps the block into a `Stmt(pos, block)` and calls a helper on that `Stmt`. This wrapping step in Rust requires cloning of the block, which is super expensive. The helper doesn't need the pos parameter, but only computes instructions from the block, so get rid of the wrapper to avoid cloning. (corresponding change in OCaml: D20236751)

Reviewed By: shiqicao

Differential Revision: D20237137

fbshipit-source-id: 8ae75d9265ef04bedb9860299d2c524eeb59b277
hphp/hack/src/hhbc/emit_statement.rs
hphp/hack/src/hhbc/env.rs
hphp/hack/src/hhbc/jump_targets.rs