From 20fc32c0c4a2518673e1cbaa0afb3c4fb284ffe6 Mon Sep 17 00:00:00 2001 From: ajreynol Date: Mon, 15 Aug 2016 16:30:07 -0500 Subject: [PATCH] Expression sharing on demand in LFSC (replace definitionally equivalent child arguments after successful comparison). --- proofs/lfsc_checker/expr.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/proofs/lfsc_checker/expr.cpp b/proofs/lfsc_checker/expr.cpp index 5cb774fbf..784a0ad2f 100644 --- a/proofs/lfsc_checker/expr.cpp +++ b/proofs/lfsc_checker/expr.cpp @@ -577,8 +577,21 @@ bool Expr::defeq(Expr *e) { { int counter = 0; while( e1->kids[counter] ){ - if( !e2->kids[counter] || !e1->kids[counter]->defeq( e2->kids[counter] ) ) - return false; + if( e1->kids[counter]!=e2->kids[counter] ){ + if( !e2->kids[counter] || !e1->kids[counter]->defeq( e2->kids[counter] ) ) + return false; + //--- optimization : replace child with equivalent pointer if was defeq + if( e1->kids[counter]kids[counter] ){ + e1->kids[counter]->dec(); + e2->kids[counter]->inc(); + e1->kids[counter] = e2->kids[counter]; + }else{ + e2->kids[counter]->dec(); + e1->kids[counter]->inc(); + e2->kids[counter] = e1->kids[counter]; + } + } + //--- counter++; } return e2->kids[counter]==NULL; -- 2.30.2