#1 2022-07-19 08:43:16

edwinsn
Member
Registered: 2010-07-02
Posts: 1,218

Not very sure about when to use TDocVariant.NewFast or TDocVariant.New

I know TDocVariant.NewFast is faster, but I'm still not very sure about when to use TDocVariant.NewFast or TDocVariant.New.

From the manual:

- by default, every internal value will be copied, so access of nested properties can be slow - if
you expect the data to be read-only or not propagated into another place, set
Options=[dvoValueCopiedByReference] will increase the process speed a lot
- in practice, you should better use _Obj()/_ObjFast() _Arr()/_ArrFast() functions or
TDocVariant.NewFast()

The obscure part is this:

if you expect the data to be read-only or not propagated into another place...

My json is not read-only, but what does "not propagated into another place" mean?

Thanks.


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#2 2022-07-19 08:45:21

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: Not very sure about when to use TDocVariant.NewFast or TDocVariant.New

It means that if you create a copy of the TDocVariant, in another variant variable for instance, and then you modify this other instance, then the first instance will also be modified.
The documentation shows this "propagation" of the modifications.

Offline

Board footer

Powered by FluxBB