com.google.protobuf.ByteString.peekCachedHashCode()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(4.1k)|赞(0)|评价(0)|浏览(237)

本文整理了Java中com.google.protobuf.ByteString.peekCachedHashCode()方法的一些代码示例,展示了ByteString.peekCachedHashCode()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ByteString.peekCachedHashCode()方法的具体详情如下:
包路径:com.google.protobuf.ByteString
类名称:ByteString
方法名:peekCachedHashCode

ByteString.peekCachedHashCode介绍

[英]Return the cached hash code if available.
[中]返回缓存的哈希代码(如果可用)。

代码示例

代码示例来源:origin: osmandapp/Osmand

@Override
public boolean equals(Object other) {
 if (other == this) {
  return true;
 }
 if (!(other instanceof ByteString)) {
  return false;
 }
 ByteString otherByteString = (ByteString) other;
 if (totalLength != otherByteString.size()) {
  return false;
 }
 if (totalLength == 0) {
  return true;
 }
 // You don't really want to be calling equals on long strings, but since
 // we cache the hashCode, we effectively cache inequality. We use the cached
 // hashCode if it's already computed.  It's arguable we should compute the
 // hashCode here, and if we're going to be testing a bunch of byteStrings,
 // it might even make sense.
 if (hash != 0) {
  int cachedOtherHash = otherByteString.peekCachedHashCode();
  if (cachedOtherHash != 0 && hash != cachedOtherHash) {
   return false;
  }
 }
 return equalsFragments(otherByteString);
}

代码示例来源:origin: com.google.protobuf/protobuf-java

@Override
public boolean equals(Object other) {
 if (other == this) {
  return true;
 }
 if (!(other instanceof ByteString)) {
  return false;
 }
 ByteString otherByteString = (ByteString) other;
 if (totalLength != otherByteString.size()) {
  return false;
 }
 if (totalLength == 0) {
  return true;
 }
 // You don't really want to be calling equals on long strings, but since
 // we cache the hashCode, we effectively cache inequality. We use the cached
 // hashCode if it's already computed.  It's arguable we should compute the
 // hashCode here, and if we're going to be testing a bunch of byteStrings,
 // it might even make sense.
 int thisHash = peekCachedHashCode();
 int thatHash = otherByteString.peekCachedHashCode();
 if (thisHash != 0 && thatHash != 0 && thisHash != thatHash) {
  return false;
 }
 return equalsFragments(otherByteString);
}

代码示例来源:origin: WeAreFairphone/FP2-Launcher

@Override
public boolean equals(Object other) {
 if (other == this) {
  return true;
 }
 if (!(other instanceof ByteString)) {
  return false;
 }
 ByteString otherByteString = (ByteString) other;
 if (totalLength != otherByteString.size()) {
  return false;
 }
 if (totalLength == 0) {
  return true;
 }
 // You don't really want to be calling equals on long strings, but since
 // we cache the hashCode, we effectively cache inequality. We use the cached
 // hashCode if it's already computed.  It's arguable we should compute the
 // hashCode here, and if we're going to be testing a bunch of byteStrings,
 // it might even make sense.
 if (hash != 0) {
  int cachedOtherHash = otherByteString.peekCachedHashCode();
  if (cachedOtherHash != 0 && hash != cachedOtherHash) {
   return false;
  }
 }
 return equalsFragments(otherByteString);
}

代码示例来源:origin: com.google.protobuf/protobuf-lite

@Override
public boolean equals(Object other) {
 if (other == this) {
  return true;
 }
 if (!(other instanceof ByteString)) {
  return false;
 }
 ByteString otherByteString = (ByteString) other;
 if (totalLength != otherByteString.size()) {
  return false;
 }
 if (totalLength == 0) {
  return true;
 }
 // You don't really want to be calling equals on long strings, but since
 // we cache the hashCode, we effectively cache inequality. We use the cached
 // hashCode if it's already computed.  It's arguable we should compute the
 // hashCode here, and if we're going to be testing a bunch of byteStrings,
 // it might even make sense.
 int thisHash = peekCachedHashCode();
 int thatHash = otherByteString.peekCachedHashCode();
 if (thisHash != 0 && thatHash != 0 && thisHash != thatHash) {
  return false;
 }
 return equalsFragments(otherByteString);
}

代码示例来源:origin: yeriomin/play-store-api

@Override
public boolean equals(Object other) {
 if (other == this) {
  return true;
 }
 if (!(other instanceof ByteString)) {
  return false;
 }
 ByteString otherByteString = (ByteString) other;
 if (totalLength != otherByteString.size()) {
  return false;
 }
 if (totalLength == 0) {
  return true;
 }
 // You don't really want to be calling equals on long strings, but since
 // we cache the hashCode, we effectively cache inequality. We use the cached
 // hashCode if it's already computed.  It's arguable we should compute the
 // hashCode here, and if we're going to be testing a bunch of byteStrings,
 // it might even make sense.
 int thisHash = peekCachedHashCode();
 int thatHash = otherByteString.peekCachedHashCode();
 if (thisHash != 0 && thatHash != 0 && thisHash != thatHash) {
  return false;
 }
 return equalsFragments(otherByteString);
}

相关文章