From 8457bf35fee253d9af29ff1150a9671f6896fc17 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 13 Mar 2013 01:30:38 +0100 Subject: MemoryObject: Use GlueGen's new HashUtil GlueGen commit 1a4514accc8f61ab7ff5fe8c82d22a5ef356c865 --- src/jogl/classes/jogamp/opengl/MemoryObject.java | 50 +++--------------------- 1 file changed, 6 insertions(+), 44 deletions(-) (limited to 'src/jogl/classes') diff --git a/src/jogl/classes/jogamp/opengl/MemoryObject.java b/src/jogl/classes/jogamp/opengl/MemoryObject.java index 292700701..df793dadd 100644 --- a/src/jogl/classes/jogamp/opengl/MemoryObject.java +++ b/src/jogl/classes/jogamp/opengl/MemoryObject.java @@ -31,19 +31,21 @@ package jogamp.opengl; import java.nio.ByteBuffer; import java.util.HashMap; +import com.jogamp.common.util.HashUtil; + /** * */ public class MemoryObject { private long addr; private long size; - private int hash32; + private int hash; private ByteBuffer buffer=null; public MemoryObject(long addr, long size) { this.addr = addr; this.size = size; - this.hash32 = getHash32(addr, size); + this.hash = HashUtil.getAddrSizeHash32_EqualDist(addr, size); } public void setBuffer(ByteBuffer buffer) { @@ -55,54 +57,14 @@ public class MemoryObject { } /** - * @return the 32bit hash value generated via {@link #getHash32(long, long)} + * @return the 32bit hash value generated via {@link HashUtil#getAddrSizeHash32_EqualDist(long, long)}. */ public int hashCode() { - return hash32; - } - - /** - * Ignores the optional attached ByteBuffer intentionally.
- * - * @return true of reference is equal or obj is of type MemoryObject - * and addr and size is equal.
- */ - public boolean equals(Object obj) { - if(this == obj) { return true; } - if(obj instanceof MemoryObject) { - MemoryObject m = (MemoryObject) obj; - return addr == m.addr && size == m.size ; - } - return false; - } - - /** - * Generates a 32bit hash value by addr and size.
- * Ignores the optional attached ByteBuffer intentionally.
- */ - public static int getHash32(long addr, long size) { - // avoid xor collisions of eg low/high parts - // 31 * x == (x << 5) - x - int hash = 31 + (int) addr ; // lo addr - hash = ((hash << 5) - hash) + (int) ( addr >>> 32 ) ; // hi addr - hash = ((hash << 5) - hash) + (int) size ; // lo size - hash = ((hash << 5) - hash) + (int) ( size >>> 32 ) ; // hi size - return hash; } - /** - * Generates a 64bit hash value by addr and size.
- * Ignores the optional attached ByteBuffer intentionally.
- */ - public static long getHash64(long addr, long size) { - // 31 * x == (x << 5) - x - final long hash = 31 + addr; - return ((hash << 5) - hash) + size; - } - public String toString() { - return "MemoryObject[addr 0x"+Long.toHexString(addr)+", size 0x"+Long.toHexString(size)+", hash32: 0x"+Integer.toHexString(hash32)+"]"; + return "MemoryObject[addr 0x"+Long.toHexString(addr)+", size 0x"+Long.toHexString(size)+", hash32: 0x"+Integer.toHexString(hash)+"]"; } /** -- cgit v1.2.3