Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Testing a variable within a range
#5
(02-06-2022, 10:37 PM)worcestersource Wrote: Actually, I've been doing some refactoring and gave the IF...THEN IF...THEN a whirl instead of using ANDs and they are about 10 bytes cheaper.

So instead of doing this:

Code:
if eventA = 0 and eventB = 0 then


Do this instead:

Code:
if eventA = 0 then if eventB = 0 then

If have a lot of ANDs in my code! I'm sure I could save quite a lot of memory here!  Smile

Steve

P.S. Would it be an idea to set up a tips and tricks bit of your forum? Such things could help us write faster, smaller code, even if it were not the most logical to read back.

That is actually very very useful to know! Thank you.  In one line only changing to "short circuit"  actually decreased my code by 13 bytes, and every byte saved is great news! Also I would expect it to perform better but I've not been able to test that but I will take it as it does :-)
Reply


Messages In This Thread
RE: Testing a variable within a range - by boriel - 01-28-2022, 11:19 AM
RE: Testing a variable within a range - by RandomiserUsr - 03-12-2022, 10:02 AM
RE: Testing a variable within a range - by boriel - 03-13-2022, 11:38 AM
RE: Testing a variable within a range - by boriel - 03-14-2022, 08:50 AM
RE: Testing a variable within a range - by boriel - 03-14-2022, 09:49 AM

Forum Jump:


Users browsing this thread: 2 Guest(s)