Skip to content

Commit 720915d

Browse files
committed
Set type for string and slice
Signed-off-by: Manjusaka <me@manjusaka.me>
1 parent 445ec7d commit 720915d

File tree

2 files changed

+13
-41
lines changed

2 files changed

+13
-41
lines changed

Python/optimizer_bytecodes.c

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -915,26 +915,16 @@ dummy_func(void) {
915915
res = sym_new_const(ctx, Py_True);
916916
}
917917

918-
op(_BUILD_TUPLE, (values[oparg] -- tup)) {
919-
tup = sym_new_tuple(ctx, oparg, values);
918+
op(_BUILD_STRING, (values[oparg] -- str)) {
919+
str = sym_new_type(ctx, &PyUnicode_Type);
920920
}
921921

922-
op(_BUILD_STRING, (values[oparg] -- str)) {
923-
bool is_const = true;
924-
for (int i = 0; i < oparg; i++) {
925-
if (!sym_is_const(ctx, values[i])) {
926-
is_const = false;
927-
break;
928-
}
929-
}
930-
if (is_const) {
931-
PyObject *val = sym_get_const(ctx, values[0]);
932-
str = sym_new_const(ctx, val);
933-
Py_DecRef(val);
934-
}
935-
else {
936-
str = sym_new_type(ctx, &PyUnicode_Type);
937-
}
922+
op(_BUILD_SLICE, (values[oparg] -- slice)) {
923+
slice = sym_new_type(ctx, &PySlice_Type);
924+
}
925+
926+
op(_BUILD_TUPLE, (values[oparg] -- tup)) {
927+
tup = sym_new_tuple(ctx, oparg, values);
938928
}
939929

940930
op(_UNPACK_SEQUENCE_TWO_TUPLE, (seq -- val1, val0)) {

Python/optimizer_cases.c.h

Lines changed: 5 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)