3
我想问一些关于我的算法的一部分的意见/建议。投射原始字体与修剪字节的方式
ByteBuffer bb = ByteBuffer.allocate(8);
bb.putLong(rs.getLong(index));//retrieve long from db (unsigned INT)
byte[] tmp = new byte[4];
bb.position(4);
bb.get(tmp);
(Inet4Address) InetAddress.getByAddress(tmp);
与
ByteBuffer bb = ByteBuffer.allocate(4);
bb.putInt((int) rs.getLong(index));//retrieve long from db (unsigned INT)
bb.flip();
byte[] tmp = new byte[4];
bb.get(tmp);
(Inet4Address) InetAddress.getByAddress(tmp);
基本上,我想知道是否有铸造性能差或者是它更好地使用更大的ByteBuffer。
感谢,问候,
马立克
将这两个块封装在方法中,编写几个测试并比较性能。为什么依靠其他人的意见,当你可以有确切的结果? – 2011-02-10 14:07:41