提交 8abadfeb authored 作者: Noel Grandin's avatar Noel Grandin

avoid extra copies in hashCode() and getBytes()

上级 d2f14480
...@@ -309,8 +309,14 @@ public class ValueLobDb extends Value implements Value.ValueClob, ...@@ -309,8 +309,14 @@ public class ValueLobDb extends Value implements Value.ValueClob,
// convert hex to string // convert hex to string
return super.getBytes(); return super.getBytes();
} }
byte[] data = getBytesNoCopy(); if (small != null) {
return Utils.cloneByteArray(data); return Utils.cloneByteArray(small);
}
try {
return IOUtils.readBytesAndClose(getInputStream(), Integer.MAX_VALUE);
} catch (IOException e) {
throw DbException.convertIOException(e, toString());
}
} }
@Override @Override
...@@ -340,7 +346,11 @@ public class ValueLobDb extends Value implements Value.ValueClob, ...@@ -340,7 +346,11 @@ public class ValueLobDb extends Value implements Value.ValueClob,
if (type == CLOB) { if (type == CLOB) {
hash = getString().hashCode(); hash = getString().hashCode();
} else { } else {
hash = Utils.getByteArrayHash(getBytes()); if (small != null) {
hash = Utils.getByteArrayHash(small);
} else {
hash = Utils.getByteArrayHash(getBytes());
}
} }
} }
return hash; return hash;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论