Skip to content

Commit 1674bb1

Browse files
committed
Don't create native byte storage for empty lists
1 parent 6675e67 commit 1674bb1

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/capi/PySequenceArrayWrapper.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public static NativeSequenceStorage executeUncached(SequenceStorage object, bool
8383
}
8484

8585
@Specialization(guards = {"!isNative(s)", "!isEmptySequenceStorage(s)", "!isMroSequenceStorage(s)"})
86-
static NativeSequenceStorage doManaged(Node inliningTarget, SequenceStorage s, @SuppressWarnings("unused") boolean isBytesLike,
86+
static NativeSequenceStorage doManaged(Node inliningTarget, SequenceStorage s, boolean isBytesLike,
8787
@Cached InlinedConditionProfile isObjectArrayProfile,
8888
@Shared("storageToNativeNode") @Cached SequenceStorageNodes.StorageToNativeNode storageToNativeNode,
8989
@Cached SequenceStorageNodes.GetInternalArrayNode getInternalArrayNode) {
@@ -127,10 +127,9 @@ static NativeSequenceStorage doNative(NativeSequenceStorage s, @SuppressWarnings
127127
}
128128

129129
@Specialization
130-
static NativeSequenceStorage doEmptyStorage(Node inliningTarget, @SuppressWarnings("unused") EmptySequenceStorage s, @SuppressWarnings("unused") boolean isBytesLike,
130+
static NativeSequenceStorage doEmptyStorage(Node inliningTarget, @SuppressWarnings("unused") EmptySequenceStorage s, boolean isBytesLike,
131131
@Shared("storageToNativeNode") @Cached SequenceStorageNodes.StorageToNativeNode storageToNativeNode) {
132-
// TODO(fa): not sure if that completely reflects semantics
133-
return storageToNativeNode.execute(inliningTarget, PythonUtils.EMPTY_BYTE_ARRAY, 0);
132+
return storageToNativeNode.execute(inliningTarget, isBytesLike ? PythonUtils.EMPTY_BYTE_ARRAY : PythonUtils.EMPTY_OBJECT_ARRAY, 0);
134133
}
135134

136135
static boolean isNative(SequenceStorage s) {

0 commit comments

Comments
 (0)