get.e

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

Matt Lewis wrote:
> 
> don cole wrote:
> > 
> >     What I want to achieve is to read the whole file in one fell swoop.
> > 
> > If I use gets() all the way through it works but takes longer.
> 
> gets() is probably the fasted way to read it.  get() is wholly inappropriate.
> As the docs state, it's for reading euphoria objects that have been 
> printed using print (though is also handles things like double and single
> quotes).  You don't say how you plan to store the data, but I'll assume you
> just want the lines concatenated:
> 
> }}}
<eucode>
> object in
> sequence s
> s = {}
> in = gets(fin)
> while( sequence( in ) ) do
>     s &= in
>     in = gets( fin )
> end while
> </eucode>
{{{

> I use this basic pattern all the time for reading files (though I usually
> keep each line in it's own sequence), and I've never had a problem with the
> 
> speed.  I recall one point in the past when people tried using things like
> get_bytes to speed up file IO, but didn't.  It seems that the actual
> hardware IO is the bottleneck.
> 
> Matt
> }}}
<eucode>
  object in
  sequence s
  integer fin
  fin=open("myfile.ew","r")
 s = {}
 in = gets(fin)
while( sequence( in ) ) do
     s &= in
    in = gets( fin )
 end while
 </eucode>
{{{


  Is what I'm using and you're saying that's faster than anything using get()?

Don Cole

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

Search



Quick Links

User menu

Not signed in.

Misc Menu