我刚刚在 DirectByteBuffer.slice() 中发现了这个:
public ByteBuffer slice() {
int pos = this.position();
int lim = this.limit();
assert (pos <= lim);
int rem = (pos <= lim ? lim - pos : 0);
int off = (pos << 0); // <---- what does this do
assert (off >= 0);
return new DirectByteBuffer(this, -1, 0, rem, rem, off);
}
将 int 左移 0 有什么意义?
最佳答案
在该类的声明之前,有如下注释:
// -- This file was mechanically generated: Do not edit! -- //
所使用的代码生成方案可能没有费心去消除 0 的移位,即使它们没有效果。
关于java - 将整数移动零次有什么影响?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27403795/