Re: getc( ) and gets( ) speed
- Posted by "Kat" <gertie at visionsix.com> Dec 15, 2003
- 522 views
On 16 Dec 2003, at 8:44, Derek Parnell wrote: > > > ----- Original Message ----- > From: "Euman" <euman at bellsouth.net> > To: <EUforum at topica.com> > Subject: Re: getc( ) and gets( ) speed > > > [snip] > > > > what about 13,10 (crlf) from each line ending > > if I have 5000 lines with 201 bytes and I need > > only 200, I would need to bypass the crlf on each > > line.. > > > > This shoot holes in the theory that using getc( ) > > is faster than gets( ) for most things. > > > > Never heard of that theory. > > But think about it, you need to call getc() for each and every character > inside > some form of (slow) Euphoria loop; but gets() only needs to be called for each > line (multiple characters per time), so in many circumstances gets() will be > faster then getc(). However, gets() only works for text files, it makes a mess > of binary files. Which makes even more sense to use fget() (or something like that) to grab the whole file from the OS into a sequence, glom the whole thing at once. Then if you want it broken into strings, parse() it on the line terminator. If it's a bitmap, blast it to the screen buffer (in pascal, i'd let dos take it from the drive directly to the screen buffer). Kat