提交 70ed289c authored 作者: Thomas Mueller's avatar Thomas Mueller

reuse empty arrays

上级 ddb57838
......@@ -10,7 +10,7 @@ import java.io.EOFException;
import java.io.IOException;
import org.h2.store.fs.FileObject;
import org.h2.util.ByteUtils;
import org.h2.util.MemoryUtils;
/**
* In this file system, files are kept fully in memory until stored.
......@@ -58,7 +58,7 @@ public class FileObjectDatabase implements FileObject {
public void setFileLength(long newLength) {
this.length = (int) newLength;
if (length != data.length) {
byte[] n = ByteUtils.newBytes(length);
byte[] n = MemoryUtils.newBytes(length);
System.arraycopy(data, 0, n, 0, Math.min(data.length, n.length));
data = n;
changed = true;
......@@ -76,7 +76,7 @@ public class FileObjectDatabase implements FileObject {
public void write(byte[] b, int off, int len) {
if (pos + len > data.length) {
int newLen = Math.max(data.length * 2, pos + len);
byte[] n = ByteUtils.newBytes(newLen);
byte[] n = MemoryUtils.newBytes(newLen);
System.arraycopy(data, 0, n, 0, length);
data = n;
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论