From a386cf7dbf2b02e406437c3cb4d804888507d4c9 Mon Sep 17 00:00:00 2001 From: Cristiano Calcagno Date: Mon, 4 Apr 2016 01:42:50 -0700 Subject: [PATCH] Fix quadratic behaviour of collect_res_trans. Reviewed By: ddino Differential Revision: D3131908 fb-gh-sync-id: e097180 fbshipit-source-id: e097180 --- infer/src/clang/cTrans_utils.ml | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/infer/src/clang/cTrans_utils.ml b/infer/src/clang/cTrans_utils.ml index a4f052ec3..9b33a9316 100644 --- a/infer/src/clang/cTrans_utils.ml +++ b/infer/src/clang/cTrans_utils.ml @@ -177,12 +177,19 @@ let collect_res_trans l = collect l' { root_nodes = root_nodes; leaf_nodes = leaf_nodes; - ids = rt.ids@rt'.ids; - instrs = rt.instrs@rt'.instrs; - exps = rt.exps@rt'.exps; - initd_exps = rt.initd_exps@rt'.initd_exps; + ids = IList.rev_append rt'.ids rt.ids; + instrs = IList.rev_append rt'.instrs rt.instrs; + exps = IList.rev_append rt'.exps rt.exps; + initd_exps = IList.rev_append rt'.initd_exps rt.initd_exps; is_cpp_call_virtual = false; } in - collect l empty_res_trans + let rt = collect l empty_res_trans in + { + rt with + ids = IList.rev rt.ids; + instrs = IList.rev rt.instrs; + exps = IList.rev rt.exps; + initd_exps = IList.rev rt.initd_exps; + } let extract_var_exp_or_fail transt_state = match transt_state.var_exp_typ with