Delphi and TValues ​​Options

I know that I am Variantsslow when I convert data types, even when I just add two variants of values ​​containing integers. I also found another similar thing that looks kind of like TValue.

What is the difference between the two?

I considered the possibility of a classic speed test with TStopWatch, but I do not think that this is enough to understand the differences

+4
source share
2 answers

TValuenot an option. It will not perform data conversions, for example Variant. If you ask TValueto return another type that it holds at the moment, and the held type is not compatible with the destination with the requested type (i.e., it usually does not imply conversion in the standard language syntax), then TValueraise an exception EInvalidCast.

+14
source

TValue It is not intended to convert data types, but to transfer values ​​when using RTTI.

, (, Integer Int64 Byte Integer). Variant , , a string, , Integer, EInvalidCast.

+16

Source: https://habr.com/ru/post/1655387/


All Articles