From 947c231a1893285771d0d20fdc9175d41875d906 Mon Sep 17 00:00:00 2001 From: Matti Tahvonen Date: Thu, 14 Aug 2008 08:18:14 +0000 Subject: [PATCH] Optimizing IndexedContainerProperty hashCode (or making it practical) svn changeset:5183/svn branch:trunk --- .../toolkit/data/util/IndexedContainer.java | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/com/itmill/toolkit/data/util/IndexedContainer.java b/src/com/itmill/toolkit/data/util/IndexedContainer.java index ea8a01756a..648db7ff7e 100644 --- a/src/com/itmill/toolkit/data/util/IndexedContainer.java +++ b/src/com/itmill/toolkit/data/util/IndexedContainer.java @@ -141,8 +141,10 @@ public class IndexedContainer implements Container, Container.Indexed, */ public Item getItem(Object itemId) { - // Null ids are not accepted - if (itemId == null) throw new NullPointerException("Container item id can not be null"); + // Null ids are not accepted + if (itemId == null) { + throw new NullPointerException("Container item id can not be null"); + } if (items.containsKey(itemId) && (filteredItemIds == null || filteredItemIds.contains(itemId))) { @@ -339,9 +341,11 @@ public class IndexedContainer implements Container, Container.Indexed, */ public Item addItem(Object itemId) { - // Null ids are not accepted - if (itemId == null) throw new NullPointerException("Container item id can not be null"); - + // Null ids are not accepted + if (itemId == null) { + throw new NullPointerException("Container item id can not be null"); + } + // Makes sure that the Item has not been created yet if (items.containsKey(itemId)) { return null; @@ -1195,8 +1199,9 @@ public class IndexedContainer implements Container, Container.Indexed, */ private IndexedContainerProperty(Object itemId, Object propertyId) { if (itemId == null || propertyId == null) { - // Null ids are not accepted - throw new NullPointerException("Container item or property ids can not be null"); + // Null ids are not accepted + throw new NullPointerException( + "Container item or property ids can not be null"); } this.propertyId = propertyId; this.itemId = itemId; @@ -1330,8 +1335,7 @@ public class IndexedContainer implements Container, Container.Indexed, * @return A locally unique hash-code as integer */ public int hashCode() { - return itemId.hashCode() ^ propertyId.hashCode() - ^ IndexedContainer.this.hashCode(); + return itemId.hashCode() ^ propertyId.hashCode(); } /** -- 2.39.5