Skip to content

Commit bf2b35f

Browse files
committed
Don't eagerly create native storages when slicing
1 parent 2c931de commit bf2b35f

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/common/SequenceStorageNodes.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -592,29 +592,25 @@ protected static SequenceStorage doManagedStorage(BasicSequenceStorage storage,
592592
}
593593

594594
@Specialization
595-
protected static NativeSequenceStorage doNativeByte(NativeByteSequenceStorage storage, int start, @SuppressWarnings("unused") int stop, int step, int length,
596-
@Bind("this") Node inliningTarget,
597-
@Cached CStructAccess.ReadByteNode readNode,
598-
@Shared @Cached StorageToNativeNode storageToNativeNode) {
595+
protected static SequenceStorage doNativeByte(NativeByteSequenceStorage storage, int start, @SuppressWarnings("unused") int stop, int step, int length,
596+
@Cached CStructAccess.ReadByteNode readNode) {
599597

600598
byte[] newArray = new byte[length];
601599
for (int i = start, j = 0; j < length; i += step, j++) {
602600
newArray[j] = readNode.readArrayElement(storage.getPtr(), i);
603601
}
604-
return storageToNativeNode.execute(inliningTarget, newArray, length);
602+
return new ByteSequenceStorage(newArray);
605603
}
606604

607605
@Specialization
608-
protected static NativeSequenceStorage doNativeObject(NativeObjectSequenceStorage storage, int start, @SuppressWarnings("unused") int stop, int step, int length,
609-
@Bind("this") Node inliningTarget,
606+
protected static SequenceStorage doNativeObject(NativeObjectSequenceStorage storage, int start, @SuppressWarnings("unused") int stop, int step, int length,
610607
@Cached CStructAccess.ReadPointerNode readNode,
611-
@Shared @Cached StorageToNativeNode storageToNativeNode,
612608
@Cached NativeToPythonNode toJavaNode) {
613609
Object[] newArray = new Object[length];
614610
for (int i = start, j = 0; j < length; i += step, j++) {
615611
newArray[j] = toJavaNode.execute(readNode.readArrayElement(storage.getPtr(), i));
616612
}
617-
return storageToNativeNode.execute(inliningTarget, newArray, length);
613+
return new ObjectSequenceStorage(newArray);
618614
}
619615

620616
@NeverDefault

0 commit comments

Comments
 (0)