java - 将整数移动零次有什么影响?

标签 java

我刚刚在 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/

相关文章:

java - 我如何使用 android espresso web 找到类名称中的所有元素并选择我需要的

java - 在 JavaFX 构建中添加外部 jar 文件

javascript - GWT jsinterop java 导出不起作用

java - 计算各种列表中出现的次数 Java

java - 为什么 Java 不能创建类型参数的实例

java - 使用 Google 的 Java API 客户端库进行身份验证时出现 IllegalArgumentException

Java HttpClient 获取 url 中含有非法字符的响应

java - 在递归方法中使用迭代循环时出现问题

java - 字符串比较 : individual comparison Vs appended string comparison

java - Prowide-Core Library - 无法在 MT564 swift 消息中获取序列 E 标签