Skip to content

Commit 0014212

Browse files
refactor
1 parent e99864d commit 0014212

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

mypyc/irbuild/ll_builder.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1568,17 +1568,8 @@ def is_string_literal(value: Value) -> TypeGuard[LoadLiteral]:
15681568
return self.primitive_op(str_eq_literal, [lhs, rhs, literal_length], line)
15691569
return self.primitive_op(str_eq, [lhs, rhs], line)
15701570
elif op == "!=":
1571-
if is_string_literal(lhs):
1572-
if is_string_literal(rhs):
1573-
# we can optimize out the check entirely in some constant-folded cases
1574-
return self.true() if lhs.value != rhs.value else self.false()
1575-
literal_length = Integer(len(lhs.value), c_pyssize_t_rprimitive, line) # type: ignore [arg-type]
1576-
eq = self.primitive_op(str_eq_literal, [rhs, lhs, literal_length], line)
1577-
elif is_string_literal(rhs):
1578-
literal_length = Integer(len(rhs.value), c_pyssize_t_rprimitive, line) # type: ignore [arg-type]
1579-
eq = self.primitive_op(str_eq_literal, [lhs, rhs, literal_length], line)
1580-
else:
1581-
eq = self.primitive_op(str_eq, [lhs, rhs], line)
1571+
# perform a standard equality check, then negate
1572+
eq = compare_strings(lhs, rhs, "==", line)
15821573
return self.add(ComparisonOp(eq, self.false(), ComparisonOp.EQ, line))
15831574

15841575
# TODO: modify 'str' to use same interface as 'compare_bytes' as it would avoid

0 commit comments

Comments
 (0)