mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2024-11-21 14:18:57 -07:00
Join InternalListFindList loops into one
This commit is contained in:
parent
36d2004a22
commit
f5035ed62d
1 changed files with 13 additions and 21 deletions
|
@ -744,28 +744,20 @@ def InternalListFindList(lst, elems, start, end, stride, instance):
|
||||||
return 0
|
return 0
|
||||||
if stride < 1:
|
if stride < 1:
|
||||||
return -1 # stride 0 or negative returns -1
|
return -1 # stride 0 or negative returns -1
|
||||||
if instance >= 0:
|
range = xrange(start, end+2-L2, stride) if instance >= 0 else xrange(
|
||||||
# Forward search
|
end+1-L2, start-1, -stride)
|
||||||
for i in xrange(start, end+2-L2, stride):
|
for i in range:
|
||||||
for j in xrange(L2):
|
for j in xrange(L2):
|
||||||
if not InternalCompareElems(lst[i+j], elems[j]):
|
if not InternalCompareElems(lst[i+j], elems[j]):
|
||||||
break # mismatch
|
break # mismatch
|
||||||
else:
|
else:
|
||||||
# no mismatch
|
# no mismatch
|
||||||
if instance == 0:
|
if instance < 0:
|
||||||
return i
|
|
||||||
instance -= 1
|
|
||||||
else:
|
|
||||||
# Backward search
|
|
||||||
for i in xrange(end+1-L2, start-1, -stride):
|
|
||||||
for j in xrange(L2):
|
|
||||||
if not InternalCompareElems(lst[i+j], elems[j]):
|
|
||||||
break # mismatch
|
|
||||||
else:
|
|
||||||
# no mismatch
|
|
||||||
instance += 1
|
instance += 1
|
||||||
if instance == 0:
|
if instance == 0:
|
||||||
return i
|
return i
|
||||||
|
if instance > 0:
|
||||||
|
instance -= 1
|
||||||
return -1
|
return -1
|
||||||
|
|
||||||
def reduce(t):
|
def reduce(t):
|
||||||
|
|
Loading…
Reference in a new issue