[Development] Qt 5.9's new garbage collector documentation? + root_ptr
Thiago Macieira
thiago.macieira at intel.com
Sat Jul 8 03:55:23 CEST 2017
On sexta-feira, 7 de julho de 2017 18:25:19 PDT Phil Bouchard wrote:
> So if for each function there is 1 root_ptr pointing to a list of local
> variables then:
> - the parameters of the function will remain unaffected if they are used
> as r-values
> - the parameters of the function will require a deep copy of the
> expression if they are used as l-values
> - closures of the function will remain unaffected if they are used as
> r-values
> - closures of the function will require a deep copy of the expression if
> they are used as l-values
> - return values will be deep copies.
JavaScript has no such thing as l or rvalues. Please define use proper terms
for the language in question.
I don't see a problem with variables being modified. But I do see a problem if
a parameter is copied to a global variable. Requiring a deep copy is wasteful
when the current code requires no such thing. So now you have to prove that
htis extra waste is offset by the benefits of using root_ptr elsewhere.
> function foo(source)
> {
> var image = new Image();
> image.height = 100;
> image.title = file.name;
> image.src = source; // parameter used as an r-value will remain
> unaffected
> return image; // return value will require 'image' to be a deep copy
> },
So if this Image object opened a 4K image @ 3840x2160 (= just under 32 MB),
you're suggesting that all 32 MB be copied?
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
More information about the Development
mailing list