I have the following code to remove prefixes from data.
msgin=:y
msgout=:''
while. 0=0 do.
if. 0={.msgin do. msgout{a. return. end.
prefixcount=:>:0{msgin
msgin=:prefixcount}.msgin NB. Drop prefix
msgout=:msgout,{.msgin NB. Append a message char
msgin=:}.msgin NB. Drop char
end.
The idea is that a prefix consists of a one byte count (#prefix)
followed by the prefix. These bytes all get removed and the
following byte is appended to the output string. If the one
byte count is zero, the data is finished.
The code works fine but takes an unacceptable amount of time
to run (several minutes for a 100,000 byte input.) The only
verbs used are {. head }. drop and , append.
How can I find which of these is calling the slowdown and is
there a quicker alternative?
Thanks in advance
_________________________________________________________________
25GB of FREE Online Storage – Find out more
http://clk.atdmt.com/UKM/go/134665320/direct/01/
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm