@@ -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