Skip to content

Commit 0602521

Browse files
Kolpatimfel
authored andcommitted
implemented startswith call with tuple on byte arrays
1 parent a6af872 commit 0602521

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/ByteArrayBuiltins.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,18 @@ public Object iter(PByteArray byteArray) {
477477
abstract static class StartsWithNode extends PythonBuiltinNode {
478478
@Child private SequenceStorageNodes.LenNode lenNode;
479479

480+
@Specialization
481+
boolean startswith(PByteArray self, PTuple prefixes, @SuppressWarnings("unused") PNone start, @SuppressWarnings("unused") PNone end,
482+
@Cached("create()") BytesNodes.FindNode findNode) {
483+
for (Object arrayObj : prefixes.getArray()) {
484+
PIBytesLike array = (PIBytesLike) arrayObj;
485+
if (startswith(self, array, start, end, findNode)) {
486+
return true;
487+
}
488+
}
489+
return false;
490+
}
491+
480492
@Specialization
481493
boolean startswith(PByteArray self, PIBytesLike prefix, @SuppressWarnings("unused") PNone start, @SuppressWarnings("unused") PNone end,
482494
@Cached("create()") BytesNodes.FindNode findNode) {

0 commit comments

Comments
 (0)