compound if alternatives

Wil Dijkstra W.Dijkstra at fsw.vu.nl
Mon Jan 26 13:13:49 EST 2004


Your script will run faster with:
...
else if c < t2 then
   do2
else if c < t3 then
   do3
...
No need to check if c >= t1 etc.; it's already catched by the previous statement.

Wil Dijkstra

-----Original Message-----
From:	Robert Brenstein [mailto:rjb at rz.uni-potsdam.de]
Sent:	Sat 1/24/2004 2:45 AM
To:	metacard at lists.runrev.com
Cc:	
Subject:	compound if alternatives

I need to repeatedly check within which of predefined time periods 
the current moment is. Since this affects overall performance (but is 
necessary), I am trying to see whether there is an alternative to a 
compound if to speed this up.

t1, t2, t3, ... , t7 -- time interval boundaries in seconds
c - current time in seconds

if c < t1 then
   do1
else if c >= t1 and c < t2 then
   do2
else if c >= t2 and c < t3 then
   do3
...
else if c >= t7 then
   do8
end if

Anyone any ideas? I seem to have a "writer's block" :(

This is for a cgi handler on a web server that controls user actions 
over a time span. For each user request I need to determine which 
time period I am in and then take appropriate action (or tell user 
that his request is not allowed at this time).

Robert
_______________________________________________
metacard mailing list
metacard at lists.runrev.com
http://lists.runrev.com/mailman/listinfo/metacard



-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/ms-tnef
Size: 2989 bytes
Desc: not available
Url : http://lists.runrev.com/pipermail/metacard/attachments/20040126/b8128965/attachment-0001.bin


More information about the metacard mailing list