Comment #3 on issue 3611 by [email protected]: Adding a new object
property is very slow
https://code.google.com/p/v8/issues/detail?id=3611
Define "later on" in JavaScript.
If you want fast object handling and fast property accesses, make sure you
use constructors and initialize all properties in those constructors.
Example:
function MyObject(foo, bar) {
this.foo = foo;
this.bar = bar;
}
var my_obj = new MyObject("foovalue", "barvalue");
my_obj.new_property = "something else"; // Don't do this!
Of course if you need actual "map"/"dictionary" semantics (as the variable
name seems to imply), i.e. you need to map a large number of keys to a
large number of values, where the keys aren't known in advance, then
starting with an empty object and adding properties as needed is your best
bet (at least, before ES6 with actual Map objects arrives). In this case,
neither the programmer nor the engine can reasonably be expected to predict
and preallocate all possible keys.
...or you could decide that the performance difference between various
approaches doesn't matter in practice in your application, and go for your
favorite syntax instead.
--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.