This commit is contained in:
Redkale
2017-02-23 15:29:04 +08:00
parent bf355cce28
commit 3bd880b061
7 changed files with 15 additions and 45 deletions

View File

@@ -7,6 +7,7 @@ package org.redkale.convert.bson;
import java.nio.*; import java.nio.*;
import java.util.function.*; import java.util.function.*;
import org.redkale.util.Utility;
/** /**
* *
@@ -78,20 +79,13 @@ public class BsonByteBufferWriter extends BsonWriter {
if (!buffer.hasRemaining()) { if (!buffer.hasRemaining()) {
buffer.flip(); buffer.flip();
buffer = supplier.get(); buffer = supplier.get();
ByteBuffer[] bufs = new ByteBuffer[this.buffers.length + 1]; this.buffers = Utility.append(this.buffers, buffer);
System.arraycopy(this.buffers, 0, bufs, 0, this.buffers.length);
bufs[this.buffers.length] = buffer;
this.buffers = bufs;
this.index++; this.index++;
} }
int len = buffer.remaining(); int len = buffer.remaining();
int size = 0; int size = 0;
while (len < byteLength) { while (len < byteLength) {
buffer = supplier.get(); this.buffers = Utility.append(this.buffers, buffer);
ByteBuffer[] bufs = new ByteBuffer[this.buffers.length + 1];
System.arraycopy(this.buffers, 0, bufs, 0, this.buffers.length);
bufs[this.buffers.length] = buffer;
this.buffers = bufs;
len += buffer.remaining(); len += buffer.remaining();
size++; size++;
} }

View File

@@ -84,20 +84,14 @@ public class JsonByteBufferWriter extends JsonWriter {
if (!buffer.hasRemaining()) { if (!buffer.hasRemaining()) {
buffer.flip(); buffer.flip();
buffer = supplier.get(); buffer = supplier.get();
ByteBuffer[] bufs = new ByteBuffer[this.buffers.length + 1]; this.buffers = Utility.append(this.buffers, buffer);
System.arraycopy(this.buffers, 0, bufs, 0, this.buffers.length);
bufs[this.buffers.length] = buffer;
this.buffers = bufs;
this.index++; this.index++;
} }
int len = buffer.remaining(); int len = buffer.remaining();
int size = 0; int size = 0;
while (len < byteLength) { while (len < byteLength) {
buffer = supplier.get(); buffer = supplier.get();
ByteBuffer[] bufs = new ByteBuffer[this.buffers.length + 1]; this.buffers = Utility.append(this.buffers, buffer);
System.arraycopy(this.buffers, 0, bufs, 0, this.buffers.length);
bufs[this.buffers.length] = buffer;
this.buffers = bufs;
len += buffer.remaining(); len += buffer.remaining();
size++; size++;
} }

View File

@@ -10,7 +10,7 @@ import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.*; import java.util.function.*;
import static org.redkale.source.FilterExpress.EQUAL; import static org.redkale.source.FilterExpress.EQUAL;
import org.redkale.util.Attribute; import org.redkale.util.*;
/** /**
* *
@@ -94,10 +94,7 @@ public class FilterJoinNode extends FilterNode {
return this; return this;
} }
if (or == signor || this.column == null) { if (or == signor || this.column == null) {
FilterNode[] newsiblings = new FilterNode[nodes.length + 1]; this.nodes = Utility.append(this.nodes, node);
System.arraycopy(nodes, 0, newsiblings, 0, nodes.length);
newsiblings[nodes.length] = node;
this.nodes = newsiblings;
if (this.column == null) this.or = signor; if (this.column == null) this.or = signor;
return this; return this;
} }

View File

@@ -10,7 +10,7 @@ import java.lang.reflect.Array;
import java.util.*; import java.util.*;
import java.util.function.*; import java.util.function.*;
import static org.redkale.source.FilterExpress.*; import static org.redkale.source.FilterExpress.*;
import org.redkale.util.Attribute; import org.redkale.util.*;
/** /**
* 注意: <br> * 注意: <br>
@@ -150,10 +150,7 @@ public class FilterNode { //FilterNode 不能实现Serializable接口 否则
return this; return this;
} }
if (or == signor) { if (or == signor) {
FilterNode[] newsiblings = new FilterNode[nodes.length + 1]; this.nodes = Utility.append(this.nodes, node);
System.arraycopy(nodes, 0, newsiblings, 0, nodes.length);
newsiblings[nodes.length] = node;
this.nodes = newsiblings;
return this; return this;
} }
FilterNode newnode = new FilterNode(this.column, this.express, this.itemand, this.value); FilterNode newnode = new FilterNode(this.column, this.express, this.itemand, this.value);

View File

@@ -11,7 +11,7 @@ import java.util.*;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import javax.persistence.Transient; import javax.persistence.Transient;
import static org.redkale.source.FilterExpress.*; import static org.redkale.source.FilterExpress.*;
import org.redkale.util.Attribute; import org.redkale.util.*;
/** /**
* *
@@ -117,10 +117,7 @@ public final class FilterNodeBean<T extends FilterBean> implements Comparable<Fi
return this; return this;
} }
if (or == signor) { if (or == signor) {
FilterNodeBean[] newsiblings = new FilterNodeBean[nodeBeans.length + 1]; this.nodeBeans = Utility.append(this.nodeBeans, node);
System.arraycopy(nodeBeans, 0, newsiblings, 0, nodeBeans.length);
newsiblings[nodeBeans.length] = node;
this.nodeBeans = newsiblings;
return this; return this;
} }
this.nodeBeans = new FilterNodeBean[]{new FilterNodeBean(this), node}; this.nodeBeans = new FilterNodeBean[]{new FilterNodeBean(this), node};

View File

@@ -264,22 +264,13 @@ public abstract class AnyValue {
} }
public DefaultAnyValue addValue(String name, String value) { public DefaultAnyValue addValue(String name, String value) {
if (name == null) return this; this.stringValues = Utility.append(this.stringValues, new Entry(name, value));
int len = this.stringValues.length;
Entry[] news = new Entry[len + 1];
System.arraycopy(this.stringValues, 0, news, 0, len);
news[len] = new Entry(name, value);
this.stringValues = news;
return this; return this;
} }
public DefaultAnyValue addValue(String name, AnyValue value) { public DefaultAnyValue addValue(String name, AnyValue value) {
if (name == null || value == null) return this; if (name == null || value == null) return this;
int len = this.entityValues.length; this.entityValues = Utility.append(this.entityValues, new Entry(name, value));
Entry[] news = new Entry[len + 1];
System.arraycopy(this.entityValues, 0, news, 0, len);
news[len] = new Entry(name, value);
this.entityValues = news;
return this; return this;
} }