From dc117c2cbfdd77ab8a76dbbd345e47aa54d799ea Mon Sep 17 00:00:00 2001 From: Sei Lisa Date: Sat, 21 Oct 2017 11:02:38 +0200 Subject: [PATCH] Use CompareTrees to optimize the == operator. Now we can. --- lslopt/lslfoldconst.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/lslopt/lslfoldconst.py b/lslopt/lslfoldconst.py index 14501d9..0f20ce8 100644 --- a/lslopt/lslfoldconst.py +++ b/lslopt/lslfoldconst.py @@ -1084,15 +1084,11 @@ class foldconst(object): del child self.FoldTree(parent, index) return - # While this is tempting, it can only be done for identifiers. - # Counterexample: llFrand(1) == llFrand(1) would - # almost always return FALSE. After CompareTrees is fixed, - # we can reinstate it. - #if self.CompareTrees(child[0], child[1]): - # # a == a -> 1 - # parent[index] = {'nt':'CONST', 't':'integer', 'value':1, - # 'SEF':True} - # return + if self.CompareTrees(child[0], child[1]): + # a == a -> 1 + parent[index] = {'nt':'CONST', 't':'integer', 'value':1, + 'SEF':True} + return return if nt in ('<=', '>=') or nt == '!=' and child[0]['t'] != 'list':