Skip to content

Commit

Permalink
use Bytes isalnum() and isdigit() in ByteArray
Browse files Browse the repository at this point in the history
  • Loading branch information
sziraqui committed Mar 6, 2018
1 parent 6ca14b8 commit 8b4324c
Showing 1 changed file with 2 additions and 18 deletions.
20 changes: 2 additions & 18 deletions python/common/org/python/types/ByteArray.java
Original file line number Diff line number Diff line change
Expand Up @@ -762,15 +762,7 @@ public org.python.Object index(java.util.List<org.python.Object> args, java.util
__doc__ = "B.isalnum() -> bool\n\nReturn True if all characters in B are alphanumeric\nand there is at least one character in B, False otherwise."
)
public org.python.Object isalnum() {
if (this.value.length == 0) {
return new org.python.types.Bool(false);
}
for (byte ch: this.value) {
if (!Bytes._isalpha(ch) && !Bytes._isnum(ch)) {
return new org.python.types.Bool(false);
}
}
return new org.python.types.Bool(true);
return (new Bytes(this.value)).isalnum();
}

@org.python.Method(
Expand All @@ -784,15 +776,7 @@ public org.python.Object isalpha() {
__doc__ = "B.isdigit() -> bool\n\nReturn True if all characters in B are digits\nand there is at least one character in B, False otherwise."
)
public org.python.Object isdigit() {
if (this.value.length == 0) {
return new org.python.types.Bool(false);
}
for (byte ch: this.value) {
if (!Bytes._isnum(ch)) {
return new org.python.types.Bool(false);
}
}
return new org.python.types.Bool(true);
return (new Bytes(this.value)).isdigit();
}

@org.python.Method(
Expand Down

0 comments on commit 8b4324c

Please sign in to comment.