Author: markt
Date: Mon Jan 15 22:16:09 2018
New Revision: 1821199
URL: http://svn.apache.org/viewvc?rev=1821199&view=rev
Log:
Pull up and align isNull and recycle
Modified:
tomcat/trunk/java/org/apache/tomcat/util/buf/AbstractChunk.java
tomcat/trunk/java/org/apache/tomcat/util/buf/ByteChunk.java
tomcat/trunk/java/org/apache/tomcat/util/buf/CharChunk.java
Modified: tomcat/trunk/java/org/apache/tomcat/util/buf/AbstractChunk.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/buf/AbstractChunk.java?rev=1821199&r1=1821198&r2=1821199&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/buf/AbstractChunk.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/buf/AbstractChunk.java Mon Jan 15
22:16:09 2018
@@ -29,6 +29,8 @@ public abstract class AbstractChunk impl
private int hashCode = 0;
protected boolean hasHashCode = false;
+ protected boolean isSet;
+
protected int start;
protected int end;
@@ -51,14 +53,6 @@ public abstract class AbstractChunk impl
}
- /**
- * @return the length of the data in the buffer
- */
- public int getLength() {
- return end - start;
- }
-
-
// TODO: Deprecate offset and use start
public int getOffset() {
@@ -74,6 +68,33 @@ public abstract class AbstractChunk impl
}
+ /**
+ * @return the length of the data in the buffer
+ */
+ public int getLength() {
+ return end - start;
+ }
+
+
+ public boolean isNull() {
+ if (end > 0) {
+ return false;
+ }
+ return !isSet;
+ }
+
+
+ /**
+ * Resets the chunk to an uninitialized state.
+ */
+ public void recycle() {
+ hasHashCode = false;
+ isSet = false;
+ start = 0;
+ end = 0;
+ }
+
+
@Override
public int hashCode() {
if (hasHashCode) {
Modified: tomcat/trunk/java/org/apache/tomcat/util/buf/ByteChunk.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/buf/ByteChunk.java?rev=1821199&r1=1821198&r2=1821199&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/buf/ByteChunk.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/buf/ByteChunk.java Mon Jan 15
22:16:09 2018
@@ -127,8 +127,6 @@ public final class ByteChunk extends Abs
private transient Charset charset;
- private boolean isSet = false; // XXX
-
// How much can it grow, when data is added
private int limit = -1;
@@ -168,20 +166,10 @@ public final class ByteChunk extends Abs
}
- public boolean isNull() {
- return !isSet; // buff==null;
- }
-
-
- /**
- * Resets the message buff to an uninitialized state.
- */
+ @Override
public void recycle() {
+ super.recycle();
charset = null;
- start = 0;
- end = 0;
- isSet = false;
- hasHashCode = false;
}
Modified: tomcat/trunk/java/org/apache/tomcat/util/buf/CharChunk.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/buf/CharChunk.java?rev=1821199&r1=1821198&r2=1821199&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/buf/CharChunk.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/buf/CharChunk.java Mon Jan 15
22:16:09 2018
@@ -68,8 +68,6 @@ public final class CharChunk extends Abs
// char[]
private char buff[];
- private boolean isSet = false; // XXX
-
// -1: grow indefinitely
// maximum amount to be cached
private int limit = -1;
@@ -101,26 +99,6 @@ public final class CharChunk extends Abs
}
- public boolean isNull() {
- if (end > 0) {
- return false;
- }
- return !isSet; // XXX
- }
-
-
- /**
- * Resets the message bytes to an uninitialized state.
- */
- public void recycle() {
- // buff=null;
- isSet = false; // XXX
- hasHashCode = false;
- start = 0;
- end = 0;
- }
-
-
// -------------------- Setup --------------------
public void allocate(int initial, int limit) {
@@ -149,6 +127,17 @@ public final class CharChunk extends Abs
}
+ // compat
+ public char[] getChars() {
+ return getBuffer();
+ }
+
+
+ public char[] getBuffer() {
+ return buff;
+ }
+
+
/**
* Maximum amount of data in this buffer. If -1 or not set, the buffer will
* grow indefinitely. Can be smaller than the current buffer size ( which
@@ -189,17 +178,6 @@ public final class CharChunk extends Abs
}
- // compat
- public char[] getChars() {
- return getBuffer();
- }
-
-
- public char[] getBuffer() {
- return buff;
- }
-
-
// -------------------- Adding data --------------------
public void append(char b) throws IOException {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]