To move the "current byte" pointer in TStream class we can use property Position (e.g. MyStream.Position := 0) or using Seek method (e.g. MyStream.Seek(0, soFromBeginning). The question is, which one is more efficient (aka faster)? (I don't have the source, so I could not check it myself).
So far I always use Seek in positioning that said pointer.
As TStream.Seek
is an overloaded function handling 32-Bit or 64-Bit values, it depends on the current stream implementation, which might be the better choice.
For instance TCustomMemoryStream
implements the 32-Bit version of Seek()
. When you set Position
on that stream this will first call the 64-Bit version, which casts the value to a Longint while calling the 32-Bit version. (This will probably change with a 64-Bit version of Delphi!)
On the other hand a THandleStream
implements the 64-Bit version of Seek()
. When you call Seek()
with a 32-Bit value you end up in a quite nasty mechanism calling the 64-Bit version.
My personal advice would be to set Position
. At least it will be the better choice in the future.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With