FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

review (wrong) asserts by kares · Pull Request #9367 · jruby/jruby · GitHub

/ jruby Public
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .java  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -220,42 +220,42 @@ public void setValueThreeDepthZeroVoid(IRubyObject value) {
public void setValueFourDepthZeroVoid(IRubyObject value) {
IRubyObject[] variableValues = this.variableValues;

assert checkOffset(variableValues, 3) : failSet(this, value, 3);
assert checkOffset(variableValues, 4) : failSet(this, value, 4);

variableValues[4] = value;
}
public void setValueFiveDepthZeroVoid(IRubyObject value) {
IRubyObject[] variableValues = this.variableValues;

assert checkOffset(variableValues, 3) : failSet(this, value, 3);
assert checkOffset(variableValues, 5) : failSet(this, value, 5);

variableValues[5] = value;
}
public void setValueSixDepthZeroVoid(IRubyObject value) {
IRubyObject[] variableValues = this.variableValues;

assert checkOffset(variableValues, 3) : failSet(this, value, 3);
assert checkOffset(variableValues, 6) : failSet(this, value, 6);

variableValues[6] = value;
}
public void setValueSevenDepthZeroVoid(IRubyObject value) {
IRubyObject[] variableValues = this.variableValues;

assert checkOffset(variableValues, 3) : failSet(this, value, 3);
assert checkOffset(variableValues, 7) : failSet(this, value, 7);

variableValues[7] = value;
}
public void setValueEightDepthZeroVoid(IRubyObject value) {
IRubyObject[] variableValues = this.variableValues;

assert checkOffset(variableValues, 3) : failSet(this, value, 3);
assert checkOffset(variableValues, 8) : failSet(this, value, 8);

variableValues[8] = value;
}
public void setValueNineDepthZeroVoid(IRubyObject value) {
IRubyObject[] variableValues = this.variableValues;

assert checkOffset(variableValues, 3) : failSet(this, value, 3);
assert checkOffset(variableValues, 9) : failSet(this, value, 9);

variableValues[9] = value;
}
Expand Down
24 changes: 11 additions & 13 deletions core/src/main/java/org/jruby/util/ByteList.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ public ByteList(byte[] wrap, int index, int len, boolean copy) {
public ByteList(byte[] wrap, int index, int len, Encoding encoding, boolean copy) {
assert wrap != null : "'wrap' must not be null";
assert index >= 0 && index <= wrap.length : "'index' is not without bounds of 'wrap' array";
assert wrap.length >= index + len : "'index' + 'len' is longer than the 'wrap' array";
assert len >= 0 : "'len' must be non-negative";
assert wrap.length - index >= len : "'len' extends beyond the 'wrap' array";

if (copy) {
bytes = new byte[len];
Expand Down Expand Up @@ -255,8 +256,9 @@ public ByteList(ByteList wrap, int index, int len) {
* @param len number of bytes to delete
*/
public void delete(int start, int len) {
assert start >= begin && start < realSize : "'start' is at invalid index";
assert len >= 0 : "'len' must be positive";
assert start >= begin : "'start' is at invalid index (< begin)";
assert start < begin + realSize : "'start' is at invalid index (>= end)";
assert len >= 0 : "'len' must be non-negative";
assert start + len <= begin + realSize : "too many bytes requested";

realSize -= len;
Expand Down Expand Up @@ -627,7 +629,8 @@ public int lengthEnc() {
* @return the byte retreived
*/
public int get(int index) {
assert index >= 0 : "index must be positive";
assert index >= 0 : "index must be non-negative";
assert begin + index < begin + realSize : "index is too large";

return bytes[begin + index] & 0xFF;
}
Expand All @@ -649,7 +652,7 @@ public int getEnc(int index) {
* @param b is the new value.
*/
public void set(int index, int b) {
assert index >= 0 : "index must be positive";
assert index >= 0 : "index must be non-negative";
assert begin + index < begin + realSize : "index is too large";

bytes[begin + index] = (byte)b;
Expand Down Expand Up @@ -1226,7 +1229,8 @@ public static byte[] plain(char[] s) {
*/
public static char[] plain(byte[] b, int start, int length) {
assert b != null : "byte array cannot be null";
assert start >= 0 && start + length <= b.length : "Invalid start or start+length too long";
assert length >= 0 : "length must be non-negative";
assert start >= 0 && start + length <= b.length : "invalid start index";

char[] chars = new char[length];
for (int i = 0; i < length; i++) {
Expand All @@ -1243,12 +1247,7 @@ public static char[] plain(byte[] b, int start, int length) {
*/
public static char[] plain(byte[] b) {
assert b != null : "byte array cannot be null";

char[] chars = new char[b.length];
for (int i = 0; i < b.length; i++) {
chars[i] = (char) (b[i] & 0xFF);
}
return chars;
return plain(b, 0, b.length);
}

// Work around bad charset handling in JDK. See
Expand Down Expand Up @@ -1433,7 +1432,6 @@ public Encoding getEncoding() {
* @param encoding the encoding to set
*/
public void setEncoding(Encoding encoding) {
assert encoding != null;
this.encoding = safeEncoding(encoding);
invalidate();
}
Expand Down

Back | FazBrowse Home | New Git URL