mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 15:48:21 +00:00
llXorBase64Strings and llModPow are not safe to precompute.
The reason is they have an embedded delay. A script might rely on it, therefore substituting the call with its value is not equivalent to leaving the call. They were both already excluded from the SEF table for the same reason.
This commit is contained in:
parent
505f7777d4
commit
e16fad0366
2 changed files with 74 additions and 72 deletions
|
@ -1461,7 +1461,8 @@ def llMD5String(s, salt):
|
|||
assert isinteger(salt)
|
||||
return hashlib.md5(zstr(s).encode('utf8') + b':' + bytes(salt)).hexdigest().decode('utf8')
|
||||
|
||||
def llModPow(base, exp, mod):
|
||||
# This function has a delay, therefore it's not safe to compute it.
|
||||
def x_llModPow(base, exp, mod):
|
||||
assert isinteger(base)
|
||||
assert isinteger(exp)
|
||||
assert isinteger(mod)
|
||||
|
@ -1809,7 +1810,8 @@ def llXorBase64(s, xor):
|
|||
L2 += 1
|
||||
return b64encode(ret).decode('utf8')
|
||||
|
||||
def llXorBase64Strings(s, xor):
|
||||
# This function has a delay, therefore it's not safe to compute it.
|
||||
def x_llXorBase64Strings(s, xor):
|
||||
assert isstring(s)
|
||||
assert isstring(xor)
|
||||
|
||||
|
|
140
testfuncs.py
140
testfuncs.py
|
@ -129,7 +129,7 @@ def testXB64S(s1, s2, expect):
|
|||
s2 = s2.decode('utf8')
|
||||
if type(expect) == str:
|
||||
expect = expect.decode('utf8')
|
||||
test('llXorBase64Strings(' + repr(s1) + ',' + repr(s2) + ')', expect)
|
||||
test('x_llXorBase64Strings(' + repr(s1) + ',' + repr(s2) + ')', expect)
|
||||
|
||||
def testXB64SC(s1, s2, expect):
|
||||
if type(s1) == str:
|
||||
|
@ -1064,75 +1064,75 @@ def do_tests():
|
|||
testXB64 ("AQCDAQCD", "AQC=", "AACCAQGD") # the only correct one
|
||||
|
||||
|
||||
test('llModPow(65535, 3, 0)', 0)
|
||||
test('llModPow(65535, 3, 41)', 34)
|
||||
test('llModPow(65535, 3, -2147483648)', 196607)
|
||||
test('llModPow(65535, 3, -2147483647)', 131071)
|
||||
test('llModPow(65533, 3, -2147483648)', 1769445)
|
||||
test('llModPow(65533, 3, -2147483645)', 1572843)
|
||||
test('llModPow(65533, 3, 2147483645)', 1966047)
|
||||
test('llModPow(65533, 3, 555)', 142)
|
||||
test('llModPow(65533, 3, 1073741823)', 1966045)
|
||||
test('llModPow(65533, 3, 1073741824)', 1769445)
|
||||
test('llModPow(65533, 3, 1073741825)', 1572845)
|
||||
test('llModPow(32767, 3, 1073741825)', 98302)
|
||||
test('llModPow(32767, 3, 107374182)', 216275)
|
||||
test('llModPow(32767, 3, 10737418)', 876887)
|
||||
test('llModPow(32767, 3, 1073741)', 230066)
|
||||
test('llModPow(32767, 3, 107374)', 54345)
|
||||
test('llModPow(32767, 3, 507374)', 161343)
|
||||
test('llModPow(32767, 3, 907374)', 346875)
|
||||
test('llModPow(32767, 3, 707374)', 690307)
|
||||
test('llModPow(32767, 3, 607374)', 139309)
|
||||
test('llModPow(32767, 3, 600374)', 146813)
|
||||
test('llModPow(32767, 3, 550374)', 389875)
|
||||
test('llModPow(32767, 3, 520374)', 301047)
|
||||
test('llModPow(32767, 3, 510374)', 36839)
|
||||
test('llModPow(32767, 3, 500374)', 115989)
|
||||
test('llModPow(32767, 3, 300374)', 83681)
|
||||
test('llModPow(32767, 3, 100374)', 23425)
|
||||
test('llModPow(32767, 3, 130374)', 64819)
|
||||
test('llModPow(32767, 3, 132374)', 66641)
|
||||
test('llModPow(32767, 3, 142374)', 93049)
|
||||
test('llModPow(32767, 3, 172374)', 59569)
|
||||
test('llModPow(32767, 3, 192374)', 66591)
|
||||
test('llModPow(32767, 3, 199374)', 112231)
|
||||
test('llModPow(32767, 3, 209374)', 54343)
|
||||
test('llModPow(32767, 3, 259374)', 84733)
|
||||
test('llModPow(32767, 3, 269374)', 49913)
|
||||
test('llModPow(32767, 3, 261374)', 85865)
|
||||
test('llModPow(32767, 3, 260374)', 2379)
|
||||
test('llModPow(32767, 3, 250374)', 78307)
|
||||
test('llModPow(32767, 3, 259375)', 99163)
|
||||
test('llModPow(32767, 3, 260000)', 254367)
|
||||
test('llModPow(32767, 3, 259999)', 90487)
|
||||
test('llModPow(32767, 3, 259500)', 19663)
|
||||
test('llModPow(32767, 3, 259750)', 29663)
|
||||
test('llModPow(32767, 3, 259850)', 49367)
|
||||
test('llModPow(32767, 3, 259800)', 164967)
|
||||
test('llModPow(32767, 3, 259790)', 137017)
|
||||
test('llModPow(32767, 3, 259770)', 64183)
|
||||
test('llModPow(32767, 3, 259780)', 237863)
|
||||
test('llModPow(32767, 3, 259785)', 162132)
|
||||
test('llModPow(32767, 3, 259782)', 85797)
|
||||
test('llModPow(32767, 3, 259781)', 157054)
|
||||
test('llModPow(32767, 2, 259781)', 1416)
|
||||
test('llModPow(32767, 2, 259782)', 257065)
|
||||
test('llModPow(32767, 3, 259782)', 85797)
|
||||
test('llModPow(-1, 3, 259782)', 251271)
|
||||
test('llModPow(-1, -3, 259782)', 251271)
|
||||
test('llModPow(0, 0, 0)', 0)
|
||||
test('llModPow(1, 0, 0)', 0)
|
||||
test('llModPow(1, 0, 1)', 0)
|
||||
test('llModPow(1, 0, 2)', 1)
|
||||
test('llModPow(1, 0, 3)', 1)
|
||||
test('llModPow(1, 0, 4)', 1)
|
||||
test('llModPow(1, 1, 1)', 0)
|
||||
test('llModPow(5, 1, 1)', 0)
|
||||
test('llModPow(5, 25, 7)', 5)
|
||||
test('llModPow(5, 25, 13)', 5)
|
||||
test('llModPow(5, 25, 17)', 12)
|
||||
test('llModPow(41, 1, 17)', 7)
|
||||
test('x_llModPow(65535, 3, 0)', 0)
|
||||
test('x_llModPow(65535, 3, 41)', 34)
|
||||
test('x_llModPow(65535, 3, -2147483648)', 196607)
|
||||
test('x_llModPow(65535, 3, -2147483647)', 131071)
|
||||
test('x_llModPow(65533, 3, -2147483648)', 1769445)
|
||||
test('x_llModPow(65533, 3, -2147483645)', 1572843)
|
||||
test('x_llModPow(65533, 3, 2147483645)', 1966047)
|
||||
test('x_llModPow(65533, 3, 555)', 142)
|
||||
test('x_llModPow(65533, 3, 1073741823)', 1966045)
|
||||
test('x_llModPow(65533, 3, 1073741824)', 1769445)
|
||||
test('x_llModPow(65533, 3, 1073741825)', 1572845)
|
||||
test('x_llModPow(32767, 3, 1073741825)', 98302)
|
||||
test('x_llModPow(32767, 3, 107374182)', 216275)
|
||||
test('x_llModPow(32767, 3, 10737418)', 876887)
|
||||
test('x_llModPow(32767, 3, 1073741)', 230066)
|
||||
test('x_llModPow(32767, 3, 107374)', 54345)
|
||||
test('x_llModPow(32767, 3, 507374)', 161343)
|
||||
test('x_llModPow(32767, 3, 907374)', 346875)
|
||||
test('x_llModPow(32767, 3, 707374)', 690307)
|
||||
test('x_llModPow(32767, 3, 607374)', 139309)
|
||||
test('x_llModPow(32767, 3, 600374)', 146813)
|
||||
test('x_llModPow(32767, 3, 550374)', 389875)
|
||||
test('x_llModPow(32767, 3, 520374)', 301047)
|
||||
test('x_llModPow(32767, 3, 510374)', 36839)
|
||||
test('x_llModPow(32767, 3, 500374)', 115989)
|
||||
test('x_llModPow(32767, 3, 300374)', 83681)
|
||||
test('x_llModPow(32767, 3, 100374)', 23425)
|
||||
test('x_llModPow(32767, 3, 130374)', 64819)
|
||||
test('x_llModPow(32767, 3, 132374)', 66641)
|
||||
test('x_llModPow(32767, 3, 142374)', 93049)
|
||||
test('x_llModPow(32767, 3, 172374)', 59569)
|
||||
test('x_llModPow(32767, 3, 192374)', 66591)
|
||||
test('x_llModPow(32767, 3, 199374)', 112231)
|
||||
test('x_llModPow(32767, 3, 209374)', 54343)
|
||||
test('x_llModPow(32767, 3, 259374)', 84733)
|
||||
test('x_llModPow(32767, 3, 269374)', 49913)
|
||||
test('x_llModPow(32767, 3, 261374)', 85865)
|
||||
test('x_llModPow(32767, 3, 260374)', 2379)
|
||||
test('x_llModPow(32767, 3, 250374)', 78307)
|
||||
test('x_llModPow(32767, 3, 259375)', 99163)
|
||||
test('x_llModPow(32767, 3, 260000)', 254367)
|
||||
test('x_llModPow(32767, 3, 259999)', 90487)
|
||||
test('x_llModPow(32767, 3, 259500)', 19663)
|
||||
test('x_llModPow(32767, 3, 259750)', 29663)
|
||||
test('x_llModPow(32767, 3, 259850)', 49367)
|
||||
test('x_llModPow(32767, 3, 259800)', 164967)
|
||||
test('x_llModPow(32767, 3, 259790)', 137017)
|
||||
test('x_llModPow(32767, 3, 259770)', 64183)
|
||||
test('x_llModPow(32767, 3, 259780)', 237863)
|
||||
test('x_llModPow(32767, 3, 259785)', 162132)
|
||||
test('x_llModPow(32767, 3, 259782)', 85797)
|
||||
test('x_llModPow(32767, 3, 259781)', 157054)
|
||||
test('x_llModPow(32767, 2, 259781)', 1416)
|
||||
test('x_llModPow(32767, 2, 259782)', 257065)
|
||||
test('x_llModPow(32767, 3, 259782)', 85797)
|
||||
test('x_llModPow(-1, 3, 259782)', 251271)
|
||||
test('x_llModPow(-1, -3, 259782)', 251271)
|
||||
test('x_llModPow(0, 0, 0)', 0)
|
||||
test('x_llModPow(1, 0, 0)', 0)
|
||||
test('x_llModPow(1, 0, 1)', 0)
|
||||
test('x_llModPow(1, 0, 2)', 1)
|
||||
test('x_llModPow(1, 0, 3)', 1)
|
||||
test('x_llModPow(1, 0, 4)', 1)
|
||||
test('x_llModPow(1, 1, 1)', 0)
|
||||
test('x_llModPow(5, 1, 1)', 0)
|
||||
test('x_llModPow(5, 25, 7)', 5)
|
||||
test('x_llModPow(5, 25, 13)', 5)
|
||||
test('x_llModPow(5, 25, 17)', 12)
|
||||
test('x_llModPow(41, 1, 17)', 7)
|
||||
|
||||
test('llListFindList([], [])', 0)
|
||||
test('llListFindList([NaN], [NaN])', 0) # I swear.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue