Speed optimisation
Rob Beynon
r.beynon at liv.ac.uk
Wed Oct 5 02:58:40 EDT 2005
Dear Colleagues,
I have a function that takes a time in this format
hh:mm:ss.s
and to which I add a variable number of seconds, then output the
updated time in the same format. hh can be greater than 24!
Here's the function. Problem is, it seems slow (I need to do this call
about 150,000 times each file I process). I would appreciate any
insights into making this function faster
function newTime oldTime,addedSec
put the replacetext(oldTime,":"," ") into splitTime
put the first word of splitTime into h
put the second word of splitTime into m
put the third word of splitTime into s
put s + addedSec into newSec
put newSec mod 60 into remainSec
put (newsec-remainSec)/60 into addedMin
put m + addedMin into newMin
put newMin mod 60 into remainMin
put (newMin-remainMin)/60 into addedHr
put h + addedHr into newHr
if length(remainSec) = 1 then put "0" & remainSec into remainSec
if length(remainMin) = 1 then put "0" & remainMin into remainMin
if length(newHr) = 1 then put "0" & newHr into newHr
put newHr & ":" & remainMin & ":" & remainSec into newTime
return newTime
end newTime
--
All best wishes,
Rob
(Created at 07:55 on 05/10/2005)
More information about the use-livecode
mailing list