RE: Faster..less memory

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

Hi kat,

    Sorry, i'm unable to look at anything because my computer is broken 
so i have to use the library computers which filter any downloads,... so 
whatever code i'm writing next is just an assumption of what ur deparse 
does and is not guranteed to work..

1) i assume that string c is the multiple delimeter in form eg {x,y,z} 
or a valid character delimeter

function deparse(sequence s,object c)
   integer L1,L2,X1,X2,Sk
   sequence R
   atom M   
   L1 = length(s) 
   if L1 then
      Sk = 1
      if sequence(c) then
         Sk = length(c) 
      end if  
      L2 = ((L1-1)*Sk) 
      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 + Sk
      end for
      R = peek({M,X2})
      machine_proc(17,M)
      return R
   end if
   return s
end function

it is untested though should work...
Jordah

Kat wrote:
> On 21 Dec 2002, at 13:43, jordah at btopenworld.com wrote:
> 
> > 
> > Hi Kat,
> > 
> >     Just wondering what did u mean by extra tricks? the code below is a 
> > real memory and timesaver and if you explain exactly what you want your 
> > deparse() to do, i can do some changes and have a very fast and less 
> > memory consuming routine.
> 
> It has to do with the declarations at the start:
> function deparse(sequence s,integer c)
> 
> You could look at the latest release of strtok v2.1, i did ask who 
> wanted it 
> over a week ago, and only Derek replied, so i made no more changes. It's 
> on 
> the webpage http://www.pell.net/warning/ai/strtok-v2-1.html
> I was thinking of adding other things, but as i don't need them, and no 
> one 
> has suggested or asked for them, i didn't. The upgrade of v2 to v2.1 was 
> to 
> add things i need. I know of only two other people using the lib.
> 
> Kat
>  
> > Also, incase u don't like it? could u make 2 versions of deparse()? i 
> > really want people to start using that routine especially for those that 
> > 
> > handle large data...
> > 
> > Maybe i should stop, bye
> > 
> > Jordah
> > Kat wrote:
> > > 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