>So, I reverted this change to the original code, but added a single >check of the current table size before doing any modifications to the map. >This is to address the issue #4, and this doesn't seem to introduce any >significant penalty. > >Would you please help review the updated webrev: > >http://cr.openjdk.java.net/~igerasim/6904367/3/webrev/ > >Sincerely yours, > >Ivan It's possible to avoid the capacity test for the general case: put { ...while loop... if (size < threshold) { modCount++; tab[i] = k; tab[i + 1] = value; ++size; } else { putAndResize(k, value, i); } return null; } private void putAndResize(Object k, Object value, int i) { if (size == MAXIMUM_CAPACITY - 1) throw new IllegalStateException("Capacity exhausted."); modCount++; Object[] tab = table; tab[i] = k; tab[i + 1] = value; ++size; resize(tab.length); // len == 2 * current capacity. } It seems faster more often than not, but it adds more (and copied) code: not sure it's worth it. -Jeff
- RFR: [6904367]: (coll) IdentityHashMap is resized before e... Ivan Gerasimov
- Re: RFR: [6904367]: (coll) IdentityHashMap is resized... Martin Buchholz
- Re: RFR: [6904367]: (coll) IdentityHashMap is res... Ivan Gerasimov
- Re: RFR: [6904367]: (coll) IdentityHashMap is resized... Jeff Hain
- Re: RFR: [6904367]: (coll) IdentityHashMap is res... Ivan Gerasimov
- Re: RFR: [6904367]: (coll) IdentityHashMap is... Jeff Hain
- Re: RFR: [6904367]: (coll) IdentityHashMap is... David Holmes
- Re: RFR: [6904367]: (coll) IdentityHashMa... Ivan Gerasimov
- Re: RFR: [6904367]: (coll) IdentityH... Doug Lea
- Re: RFR: [6904367]: (coll) Ident... Ivan Gerasimov
- Re: RFR: [6904367]: (coll) I... Jeff Hain
- Re: RFR: [6904367]: (coll) I... Ivan Gerasimov
- Re: RFR: [6904367]: (coll) I... Ivan Gerasimov
- Re: RFR: [6904367]: (coll) I... Peter Levart
- Re: RFR: [6904367]: (coll) I... Peter Levart
- Re: RFR: [6904367]: (coll) I... Peter Levart
- Re: RFR: [6904367]: (coll) I... Ivan Gerasimov
- Re: RFR: [6904367]: (coll) I... Peter Levart
- Re: RFR: [6904367]: (coll) I... Peter Levart
- Re: RFR: [6904367]: (coll) I... Peter Levart
- Re: RFR: [6904367]: (coll) I... Ivan Gerasimov
