mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 07:38:21 +00:00
llModPow precision has been fixed and the delay removed
This commit is contained in:
parent
e27ece3536
commit
23e71354c5
6 changed files with 34 additions and 44 deletions
|
@ -1144,7 +1144,7 @@ void llMessageLinked(integer linknum, integer num, string str, key id)
|
|||
void llMinEventDelay(float delay)
|
||||
|
||||
integer llModPow(integer a, integer b, integer c)
|
||||
- delay 1.0
|
||||
- SEF
|
||||
|
||||
void llModifyLand(integer action, integer brush)
|
||||
|
||||
|
|
|
@ -1797,15 +1797,9 @@ def llModPow(base, exp, mod):
|
|||
base = fi(base)
|
||||
exp = fi(exp)
|
||||
mod = fi(mod)
|
||||
if not lslcommon.IsCalc:
|
||||
# This function has a delay, therefore it's not safe to compute it
|
||||
# unless in calculator mode.
|
||||
raise ELSLCantCompute
|
||||
# With some luck, this works fully with native ints on 64 bit machines.
|
||||
if mod in (0, 1):
|
||||
return 0
|
||||
if exp == 0:
|
||||
return 1
|
||||
# Convert all numbers to unsigned
|
||||
base &= 0xFFFFFFFF
|
||||
exp &= 0xFFFFFFFF
|
||||
|
@ -1814,11 +1808,11 @@ def llModPow(base, exp, mod):
|
|||
ret = 1
|
||||
while True:
|
||||
if exp & 1:
|
||||
ret = ((ret * prod) & 0xFFFFFFFF) % mod
|
||||
ret = ((ret * prod) % mod) & 0xFFFFFFFF
|
||||
exp = exp >> 1
|
||||
if exp == 0:
|
||||
break
|
||||
prod = ((prod * prod) & 0xFFFFFFFF) % mod
|
||||
prod = ((prod * prod) % mod) & 0xFFFFFFFF
|
||||
|
||||
return S32(ret)
|
||||
|
||||
|
|
|
@ -541,8 +541,6 @@ class UnitTestCoverage(UnitTestCase):
|
|||
# The SEF table prevents this assertion from being reachable via script.
|
||||
self.assertRaises(lslfuncs.ELSLCantCompute, lslfuncs.llXorBase64Strings,
|
||||
u"AABA", u"AABA")
|
||||
self.assertRaises(lslfuncs.ELSLCantCompute, lslfuncs.llModPow,
|
||||
3, 5, 7)
|
||||
# Check invalid type in llGetListEntryType
|
||||
self.assertRaises(lslfuncs.ELSLInvalidType, lslfuncs.llGetListEntryType,
|
||||
[b'a'], 0)
|
||||
|
|
|
@ -1,29 +1,29 @@
|
|||
[ 0
|
||||
, 34
|
||||
, 196607
|
||||
, 131071
|
||||
, 65541
|
||||
, 1769445
|
||||
, 1572843
|
||||
, 1966047
|
||||
, 1376283
|
||||
, 2162607
|
||||
, 142
|
||||
, 1966045
|
||||
, 2031553
|
||||
, 1769445
|
||||
, 1572845
|
||||
, 98302
|
||||
, 216275
|
||||
, 876887
|
||||
, 230066
|
||||
, 1507337
|
||||
, 65538
|
||||
, 229363
|
||||
, 884663
|
||||
, 253138
|
||||
, 54345
|
||||
, 161343
|
||||
, 346875
|
||||
, 690307
|
||||
, 139309
|
||||
, 146813
|
||||
, 389875
|
||||
, 301047
|
||||
, 36839
|
||||
, 115989
|
||||
, 83681
|
||||
, 713029
|
||||
, 567153
|
||||
, 209161
|
||||
, 38513
|
||||
, 486049
|
||||
, 101347
|
||||
, 377011
|
||||
, 130123
|
||||
, 3151
|
||||
, 23425
|
||||
, 64819
|
||||
, 66641
|
||||
|
@ -33,28 +33,28 @@
|
|||
, 112231
|
||||
, 54343
|
||||
, 84733
|
||||
, 49913
|
||||
, 85865
|
||||
, 2379
|
||||
, 118153
|
||||
, 155593
|
||||
, 100545
|
||||
, 78307
|
||||
, 99163
|
||||
, 254367
|
||||
, 90487
|
||||
, 21663
|
||||
, 134302
|
||||
, 19663
|
||||
, 29663
|
||||
, 49367
|
||||
, 164967
|
||||
, 137017
|
||||
, 215863
|
||||
, 118663
|
||||
, 256033
|
||||
, 64183
|
||||
, 237863
|
||||
, 162132
|
||||
, 85797
|
||||
, 104023
|
||||
, 77287
|
||||
, 157054
|
||||
, 1416
|
||||
, 257065
|
||||
, 85797
|
||||
, 251271
|
||||
, 251271
|
||||
, 77287
|
||||
, 227313
|
||||
, 42471
|
||||
, 0
|
||||
, 0
|
||||
, 0
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
// Check that the LSL functions with side effects are not computed.
|
||||
default{timer(){
|
||||
llModPow(4, 1, 2);
|
||||
llXorBase64Strings("AB", "CD");
|
||||
}}
|
||||
|
|
|
@ -2,7 +2,6 @@ default
|
|||
{
|
||||
timer()
|
||||
{
|
||||
llModPow(4, 1, 2);
|
||||
llXorBase64Strings("AB", "CD");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue