Re: Faster..less memory

new topic     » goto parent     » topic index » view thread      » older message » newer message

On 24 Oct 2002, at 11:55, jordah ferguson wrote:

> 
> Hi all,
> for those of you who use strtok routines. here is a faster deparse that 
> uses 4 times less memory. i used to get my program running out of memory 
> using the old routine. 
> 
> Enjoy, AND ladies and gentlemen, please start posting interesting code 
> fragments you come up with. cause many small cool routines are ignored 
> in bulky source code
> 
> Jordah Ferguson

Note this won't support the current strtok-v2 release, which allows deparsing 
on multiple separators at once. Neither will it support v3, which has another 
trick,, err, ability.

Kat

> function deparse(sequence s,integer c)
>    integer L1,L2,X1,X2 
>    sequence R
>    atom M   
>    L1 = length(s) 
>    if L1 then
>       L2 = (L1 - 1)   
>       for n = 1 to L1 by 1 do
>      L2 = L2 + length(s[n])
>       end for
>       M = machine_func(16, L2) 
>       X1 = 0
>       for n = 1 to L1 by 1 do
>      R = s[n]
>      X2 = X1 + length(R)
>      poke(M + X1,R)          
>      poke(M + X2,c) 
>      X1 = X2 + 1
>       end for
>       R = peek({M,X2})
>       machine_proc(17,M)
>       return R
>    end if
>    return s
> end function
> 
> 
> 
>

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu