I know that Variants are slow when I convert data types, even when I simply add two variant values holding integers. I have discovered also another similar thing that looks variant-like called TValue.
What's the difference between them?
I was considering to make a classic speed test using the TStopWatch, but I don't think that it is enough to understand the differences
TValue is not meant for converting data types but for transportation of values when using RTTI.
It only allows for data types to be converted that are directly assignment compatible (like for example Integer to Int64 or Byte to Integer). But unlike Variant it does not allow for example converting a string containing a number to be cast to Integer but raises an EInvalidCast exception.
TValue is not Variant-like.  It will not perform data conversions like Variant does.  If you ask TValue to return a different type than it is currently holding, and the held type is not assignment-compatible with the requested type, (ie it would not normally implicitly convert in normal language syntax), then TValue will raise an EInvalidCast exception.
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