Status: New
Owner: ----
New issue 479 by daniel.danilatos: "foreach" implementation is slow with
early exit
http://code.google.com/p/v8/issues/detail?id=479
In javascript, it is common to use this idiom to test if an object is empty:
function isEmpty(obj) {
for (var k in obj) {
return false;
}
return true;
}
On Chrome, this is very fast if obj is empty, but slow if obj has many
fields.
On Firefox, it takes about the same time for both cases.
I assume there's some kind of copying, or something, going on to setup
the iterator? I have no idea if this is even desirable to fix for the use
case of
looping through the whole object, but I think the early-exit use case is
fairly common too.
I have a demo that demonstrates this (profiles a few other things too).
Compare the "isEmpty" and "isEmptyBreak" values in the "empty" columns
vs the "full" columns. (Wait a few seconds for it to finish)
http://www.danilatos.com/event-test/jsomap.html
Safari also seems to have this problem too (coincidentally?)
Google Chrome 4.0.222.5 (Official Build 28804)
WebKit 532.2
V8 1.3.15
User Agent Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_6; en-US)
AppleWebKit/532.2 (KHTML, like Gecko) Chrome/4.0.222.5 Safari/532.2
--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings
--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---