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
|
||||
if stride < 1:
|
||||
return -1 # stride 0 or negative returns -1
|
||||
if instance >= 0:
|
||||
# Forward search
|
||||
for i in xrange(start, end+2-L2, stride):
|
||||
for j in xrange(L2):
|
||||
if not InternalCompareElems(lst[i+j], elems[j]):
|
||||
break # mismatch
|
||||
else:
|
||||
# no mismatch
|
||||
if instance == 0:
|
||||
return i
|
||||
instance -= 1
|
||||
else:
|
||||
# Backward search
|
||||
for i in xrange(end+1-L2, start-1, -stride):
|
||||
range = xrange(start, end+2-L2, stride) if instance >= 0 else xrange(
|
||||
end+1-L2, start-1, -stride)
|
||||
for i in range:
|
||||
for j in xrange(L2):
|
||||
if not InternalCompareElems(lst[i+j], elems[j]):
|
||||
break # mismatch
|
||||
else:
|
||||
# no mismatch
|
||||
if instance < 0:
|
||||
instance += 1
|
||||
if instance == 0:
|
||||
return i
|
||||
if instance > 0:
|
||||
instance -= 1
|
||||
return -1
|
||||
|
||||
def reduce(t):
|
||||
|
|
Loading…
Reference in a new issue