DESCRIPTION

Bug 489304 - Unefficient iteration on Map.keySet

Change-Id: Ief0f4e81e1b41460b1b1ddea0869fa5d5f8da3ec
Signed-off-by: Isis Velasquez xxx@xxx.xxx


COMMENTS

author: Isis Velasquez
date: 2016-03-10 10:02:50.000000000

Uploaded patch set 2.

-------------------------------------
author: Zaid Mosley
date: 2016-03-10 10:14:25.000000000

Patch Set 2: Code-Review+1 Verified+1

Looks fine to me, I don't know why this should be faster but I trust Sonar, Mickael and Sergey. Also the code is better readable.

-------------------------------------
author: Isis Velasquez
date: 2016-03-10 10:40:13.000000000

Patch Set 2:

It's faster because:
* for (entry:map.entrySet()) entry.getValue(); simply used the returned values without computing nor resolving anything
* for (key:map.keySet()) map.get(key); computes the hashCode and resolves in the map.
So it saves as many lookups as there are element on the map.

With Groovy shell CLI, I tried an example: a Map<String, int> where the key is the String representation of the number and the value is the value (such as "0":0, "1",1, "432432":432432...), and made this map from 0 to 10000000.
Then I iterated on that map to comupte the sum of all the values.
Iterating with keySet and looking up for value cost me about 5 seconds; iterating on entrySet cost me less than 1 second.

-------------------------------------
author: Zaid Mosley
date: 2016-03-10 10:51:17.000000000

Patch Set 2:

thanks, feel free to merge, Sergey already gave +1

-------------------------------------
author: Isis Velasquez
date: 2016-03-10 10:52:10.000000000

Patch Set 2:

I'm waiting for Tests to be successful. I'll merge that once I get a +1 from Hudson.

-------------------------------------
author: Brenden Conley
date: 2016-03-10 10:57:18.000000000

Patch Set 2:

Build Started https://hudson.eclipse.org/platform/job/eclipse.platform.ui-Gerrit/8588/

-------------------------------------
author: Brenden Conley
date: 2016-03-10 11:47:04.000000000

Patch Set 2: Verified+1

Build Successful 

https://hudson.eclipse.org/platform/job/eclipse.platform.ui-Gerrit/8588/ : SUCCESS

-------------------------------------
author: Gerrit Code Review
date: 2016-03-10 11:54:00.000000000

Change has been successfully merged into the git repository by Isis Velasquez

-------------------------------------
