Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Call invalidate() anywhere we're making a visible change to ByteList …

…contents.
  • Loading branch information...
commit ee8210eb3960e1c4ab357959cb1274607539f74c 1 parent a95bbbd
@headius headius authored
Showing with 19 additions and 0 deletions.
  1. +19 −0 src/org/jruby/util/ByteList.java
View
19 src/org/jruby/util/ByteList.java
@@ -264,6 +264,7 @@ public void delete(int start, int len) {
realSize -= len;
System.arraycopy(bytes, start + len, bytes, start, realSize);
+ invalidate();
}
/**
@@ -277,6 +278,7 @@ public void fill(int b, int len) {
for ( ; --len >= 0; ) {
append(b);
}
+ invalidate();
}
/**
@@ -339,6 +341,7 @@ public void ensure(int length) {
byte[] tmp = new byte[length + (length >>> 1)];
System.arraycopy(bytes, begin, tmp, 0, realSize);
bytes = tmp;
+ invalidate();
}
}
@@ -371,6 +374,7 @@ public ByteList makeShared(int index, int len) {
public void view(int index, int len) {
realSize = len;
begin = begin + index;
+ invalidate();
}
/**
@@ -416,6 +420,7 @@ public void prepend(byte b) {
System.arraycopy(bytes, begin + 0, bytes, begin + 1, realSize);
bytes[begin + 0] = b;
realSize++;
+ invalidate();
}
/**
@@ -428,6 +433,7 @@ public ByteList append(byte b) {
grow(1);
bytes[begin + realSize] = b;
realSize++;
+ invalidate();
return this;
}
@@ -466,6 +472,7 @@ public ByteList append(InputStream input, int length) throws IOException {
}
realSize += read;
+ invalidate();
return this;
}
@@ -480,6 +487,7 @@ public void append(ByteBuffer buffer, int len) {
grow(len);
buffer.get(bytes, begin + realSize, len);
realSize += len;
+ invalidate();
}
/**
@@ -493,6 +501,7 @@ public void append(byte[] moreBytes) {
grow(moreBytes.length);
System.arraycopy(moreBytes, 0, bytes, begin + realSize, moreBytes.length);
realSize += moreBytes.length;
+ invalidate();
}
/**
@@ -533,6 +542,7 @@ public void append(byte[] moreBytes, int start, int len) {
grow(len);
System.arraycopy(moreBytes, start, bytes, begin + realSize, len);
realSize += len;
+ invalidate();
}
/**
@@ -549,6 +559,7 @@ public void realloc(int length) {
byte tmp[] = new byte[length];
System.arraycopy(bytes, 0, tmp, 0, realSize);
bytes = tmp;
+ invalidate();
}
/**
@@ -615,6 +626,7 @@ public void set(int index, int b) {
assert begin + index < begin + realSize : "index is too large";
bytes[begin + index] = (byte)b;
+ invalidate();
}
/**
@@ -630,6 +642,7 @@ public void replace(byte[] newBytes) {
assert newBytes != null;
this.bytes = newBytes;
realSize = newBytes.length;
+ invalidate();
}
/**
@@ -658,6 +671,7 @@ public void unsafeReplace(int beg, int len, byte[] nbytes, int index, int count)
System.arraycopy(bytes,beg+len,bytes,beg+count,realSize - (len+beg));
System.arraycopy(nbytes,index,bytes,beg,count);
realSize = newSize;
+ invalidate();
}
/**
@@ -698,6 +712,7 @@ public void insert(int index, int b) {
System.arraycopy(bytes, index, bytes, index + 1, realSize - index);
bytes[index] = (byte)b;
realSize++;
+ invalidate();
}
/**
@@ -1310,6 +1325,7 @@ public static int memcmp(final byte[] first, final int firstStart, final byte[]
public final void setUnsafeBytes(byte[] bytes) {
assert bytes != null;
this.bytes = bytes;
+ invalidate();
}
/**
@@ -1325,6 +1341,7 @@ public final int getBegin() {
public final void setBegin(int begin) {
assert begin >= 0;
this.begin = begin;
+ invalidate();
}
/**
@@ -1340,6 +1357,7 @@ public final int getRealSize() {
public final void setRealSize(int realSize) {
assert realSize >= 0;
this.realSize = realSize;
+ invalidate();
}
/**
@@ -1355,6 +1373,7 @@ public final Encoding getEncoding() {
public final void setEncoding(Encoding encoding) {
assert encoding != null;
this.encoding = safeEncoding(encoding);
+ invalidate();
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.