Finish fixing the optimization
I wrote it ages ago, I was not as skilled as I am now.
This commit is contained in:
parent
f4a4b847af
commit
d7145171de
@ -506,17 +506,15 @@ def selection_and_product(n: parser.Node, rels: Dict[str, Relation]) -> parser.N
|
|||||||
if j in r_attr: # Field in right
|
if j in r_attr: # Field in right
|
||||||
r_fields = True
|
r_fields = True
|
||||||
|
|
||||||
if l_fields and r_fields: # Fields in both
|
if l_fields and not r_fields:
|
||||||
both.append(i)
|
|
||||||
elif l_fields:
|
|
||||||
left.append(i)
|
left.append(i)
|
||||||
elif r_fields:
|
elif r_fields and not l_fields:
|
||||||
right.append(i)
|
right.append(i)
|
||||||
else: # Unknown.. adding in both
|
else: # Unknown.. adding in both
|
||||||
both.append(i)
|
both.append(i)
|
||||||
|
|
||||||
# Preparing left selection
|
# Preparing left selection
|
||||||
if len(left) > 0:
|
if left:
|
||||||
l_prop = ''
|
l_prop = ''
|
||||||
while len(left) > 0:
|
while len(left) > 0:
|
||||||
c = left.pop(0)
|
c = left.pop(0)
|
||||||
@ -531,8 +529,7 @@ def selection_and_product(n: parser.Node, rels: Dict[str, Relation]) -> parser.N
|
|||||||
l_node = n.child.left
|
l_node = n.child.left
|
||||||
|
|
||||||
# Preparing right selection
|
# Preparing right selection
|
||||||
if len(right) > 0:
|
if right:
|
||||||
|
|
||||||
r_prop = ''
|
r_prop = ''
|
||||||
while len(right) > 0:
|
while len(right) > 0:
|
||||||
c = right.pop(0)
|
c = right.pop(0)
|
||||||
@ -548,8 +545,8 @@ def selection_and_product(n: parser.Node, rels: Dict[str, Relation]) -> parser.N
|
|||||||
b_node = parser.Binary(n.child.name, l_node, r_node)
|
b_node = parser.Binary(n.child.name, l_node, r_node)
|
||||||
|
|
||||||
# Changing main selection
|
# Changing main selection
|
||||||
|
if both:
|
||||||
both_prop = ''
|
both_prop = ''
|
||||||
if len(both) != 0:
|
|
||||||
while len(both) > 0:
|
while len(both) > 0:
|
||||||
c = both.pop(0)
|
c = both.pop(0)
|
||||||
both_prop += ' '.join(c)
|
both_prop += ' '.join(c)
|
||||||
@ -557,7 +554,8 @@ def selection_and_product(n: parser.Node, rels: Dict[str, Relation]) -> parser.N
|
|||||||
both_prop += ' and '
|
both_prop += ' and '
|
||||||
if '(' in both_prop:
|
if '(' in both_prop:
|
||||||
both_prop = '(%s)' % both_prop
|
both_prop = '(%s)' % both_prop
|
||||||
return parser.Unary(SELECTION, both_prop, b_node), 1
|
r = parser.Unary(SELECTION, both_prop, b_node)
|
||||||
|
return r, len(left) + len(right)
|
||||||
else: # No need for general select
|
else: # No need for general select
|
||||||
return b_node, 1
|
return b_node, 1
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user