db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan Hlavatý <hla...@code.cz>
Subject [PATCH] Optimization of org.apache.derby.impl.services.uuid.BasicUUID.toByteArray()
Date Wed, 01 Sep 2004 05:17:52 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Removed unnecessary &'s (these are done automatically by conversion to byte).
Saves 32 bytecode instructions as well as several long constants in the classfile,
and should run a bit faster.


Index: java/engine/org/apache/derby/impl/services/uuid/BasicUUID.java
===================================================================
- --- java/engine/org/apache/derby/impl/services/uuid/BasicUUID.java	(revision 37291)
+++ java/engine/org/apache/derby/impl/services/uuid/BasicUUID.java	(working copy)
@@ -279,26 +279,26 @@
~ 		byte[] result = new byte[16];

~ 		int lsequence = sequence;
- -		result[0] = (byte)((lsequence & 0xff000000) >>> 24);
- -		result[1] = (byte)((lsequence & 0x00ff0000) >>> 16);
- -		result[2] = (byte)((lsequence & 0x0000ff00) >>> 8);
- -		result[3] = (byte) (lsequence & 0x000000ff);
+		result[0] = (byte)(lsequence >>> 24);
+		result[1] = (byte)(lsequence >>> 16);
+		result[2] = (byte)(lsequence >>> 8);
+		result[3] = (byte)lsequence;

~ 		long ltimemillis = timemillis;
- -		result[4] = (byte)((ltimemillis & 0x0000ff0000000000L) >>> 40);
- -		result[5] = (byte)((ltimemillis & 0x000000ff00000000L) >>> 32);
- -		result[6] = (byte)((ltimemillis & 0x00000000ff000000L) >>> 24);
- -		result[7] = (byte)((ltimemillis & 0x0000000000ff0000L) >>> 16);
- - 		result[8] = (byte)((ltimemillis & 0x000000000000ff00L) >>> 8);
- -		result[9] = (byte) (ltimemillis & 0x00000000000000ffL);
+		result[4] = (byte)(ltimemillis >>> 40);
+		result[5] = (byte)(ltimemillis >>> 32);
+		result[6] = (byte)(ltimemillis >>> 24);
+		result[7] = (byte)(ltimemillis >>> 16);
+ 		result[8] = (byte)(ltimemillis >>> 8);
+		result[9] = (byte)ltimemillis;

~ 		long linetaddr = majorId;
- -		result[10] = (byte)((linetaddr & 0x0000ff0000000000L) >>> 40);
- -		result[11] = (byte)((linetaddr & 0x000000ff00000000L) >>> 32);
- -		result[12] = (byte)((linetaddr & 0x00000000ff000000L) >>> 24);
- -		result[13] = (byte)((linetaddr & 0x0000000000ff0000L) >>> 16);
- -		result[14] = (byte)((linetaddr & 0x000000000000ff00L) >>> 8);
- -		result[15] = (byte) (linetaddr & 0x00000000000000ffL);
+		result[10] = (byte)(linetaddr >>> 40);
+		result[11] = (byte)(linetaddr >>> 32);
+		result[12] = (byte)(linetaddr >>> 24);
+		result[13] = (byte)(linetaddr >>> 16);
+		result[14] = (byte)(linetaddr >>> 8);
+		result[15] = (byte)linetaddr;

~ 		return result;
~ 	}

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iQEUAwUBQTVbgHFDePgyse5HAQI8yQf42ETD0IDcjG/lZOHoF/nc3idA1z1duOUX
EITGEQn78vii7G8jYqCli2Hqj9OscA3uSTw+RnfOwFFMZTEV9UnbM4r+BRzZVAEe
QfAcRMHDx0H65SjCk5YKf69BgfTEEc5KjvWMYJLwIGz6PxNWpJPpYk3yVoMfByrr
3iM65Gazi/+dV8YhTu+XAIoYGi/i2o2lkWfLQu7Jh0S1sTuua5CQF16DdWC18CAz
+zwOsKGX4smNk/o0HdkGDqHsFuLmw8x5ewYMXSPh9/50Bd5hYrX7B5iRv3VoqPLp
GgB0mu8ro8XoGpsx9pIqUngwY1nmoNlB9HZj1Dq/MMGjLB31SDc1
=eovL
-----END PGP SIGNATURE-----

Mime
View raw message