You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
646 B

  1. /* Fast unicode equal function optimized for dictobject.c and setobject.c */
  2. /* Return 1 if two unicode objects are equal, 0 if not.
  3. * unicode_eq() is called when the hash of two unicode objects is equal.
  4. */
  5. Py_LOCAL_INLINE(int)
  6. unicode_eq(PyObject *aa, PyObject *bb)
  7. {
  8. register PyUnicodeObject *a = (PyUnicodeObject *)aa;
  9. register PyUnicodeObject *b = (PyUnicodeObject *)bb;
  10. if (a->length != b->length)
  11. return 0;
  12. if (a->length == 0)
  13. return 1;
  14. if (a->str[0] != b->str[0])
  15. return 0;
  16. if (a->length == 1)
  17. return 1;
  18. return memcmp(a->str, b->str, a->length * sizeof(Py_UNICODE)) == 0;
  19. }