1. RE: Efficiency
- Posted by jordah ferguson <jorfergie03 at yahoo.com> Oct 28, 2002
- 594 views
Hi Don, Actually Don, the code below is faster > [poking a string into memory] > poke( ADDR, STR ) -- poke the string > poke( ADDR+length(STR), 0 ) -- poke the null terminator Think of it this way, it will all vary on the length of string you are poking into memory. what if the string is very long, Euphoria would have to re-allocate memory for the concat then poke.... why not just poke the string then poke the null... think about it. on my old computer 33mhz. i tested and found out the above method was faster. Jordah Don Phillips wrote: > In my off time, I sometimes like to browze a lot of the programs > in the contributions and vault pages. Lots of good programs > and knowledge floating around out there. > > Time and time again, I keep seeing patterns in some of the code. > In particular, this little snip (or variations of it) crop up > quite consistantly: > > [poking a string into memory] > poke( ADDR, STR ) -- poke the string > poke( ADDR+length(STR), 0 ) -- poke the null terminator > > To me, this looks like it would be slower than the following: > > [poking a string into memory] > poke( ADDR, STR & 0 ) -- poke the string > or > poke( ADDR, STR & {0} ) -- poke the string > > Is there something about concatenating sequences in Euphoria > that would slow these two down sufficiently that the first > example is preferable? > > Don > >