db-derby-dev mailing list archives

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

Daniel John Debrunner wrote:
| Jan Hlavatý wrote:
|
| | 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.
|
| I think you are correct, but I also have a very vague memory of some
| issues if we didn't use the &'s.

There are issues with sign extension when doing it the other way around
(stuffing bytes to int/long) - thats when you need ands. Maybe thats what is haunting you
;)

| I know this is early code and we
| (Cloudscape engineers) were following the examples from Sun, e.g. look
| at this extract from the Javadoc for java.io.DataOutput.writeShort.
|
| http://java.sun.com/j2se/1.4.2/docs/api/java/io/DataOutput.html#writeShort(int)
|
|
| The byte values to be written, in the order shown, are:
|
| ~ (byte)(0xff & (v >> 8))
| ~ (byte)(0xff & v)

Well I can't make any sense of it... why the hell would they and with 0xff?
Do they have bytes larger than 8 bits or something ;)
Or maybe its just braindead code ;)

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

iQEVAwUBQTYgHHFDePgyse5HAQKqIAgAjaX+pm6t0iXzOod4pHI0sySh8FqdIML+
luTRpPqAjLaHT6L6+xPh210J2KRn3ASUpIpch0DruY3NKsBkk38DMQ9wjevh6imq
7/ahWtSe1ISPstYjFxBRwavJF4uK412TsW5sJ4NhIZGMSnvq8JGQPfNvAKRqCxEZ
nkbAsy1ADcHpQtYhSDiMv97rNGWmBqbsBP2QaTcJrciWHjdJxh4/z+JM5jtshefa
/SuCvYcnkU6puw+jVBIfV+hf96WETQ8bzatMA/nw23VSHH0YUT4YYDs+aiCfYKce
2yf/4anxPSGWS5Y+5i0YIF7cc1xGtt3fCKN8NSI3aBEdAY0qkZfnmA==
=SnyD
-----END PGP SIGNATURE-----

Mime
View raw message