+ return equal(s1.impl(), s2);
+}
+
+// This method assumes that all simple checks have been performed by
+// the inlined operator==() in the header file.
+bool equalSlowCase(const UString& s1, const UString& s2)
+{
+ StringImpl* rep1 = s1.impl();
+ StringImpl* rep2 = s2.impl();
+ unsigned size1 = rep1->length();
+
+ // At this point we know
+ // (a) that the strings are the same length and
+ // (b) that they are greater than zero length.
+ bool s1Is8Bit = rep1->is8Bit();
+ bool s2Is8Bit = rep2->is8Bit();
+
+ if (s1Is8Bit) {
+ const LChar* d1 = rep1->characters8();
+ if (s2Is8Bit) {
+ const LChar* d2 = rep2->characters8();
+
+ if (d1 == d2) // Check to see if the data pointers are the same.
+ return true;
+
+ // Do quick checks for sizes 1 and 2.
+ switch (size1) {
+ case 1:
+ return d1[0] == d2[0];
+ case 2:
+ return (d1[0] == d2[0]) & (d1[1] == d2[1]);
+ default:
+ return (!memcmp(d1, d2, size1 * sizeof(LChar)));
+ }
+ }
+
+ const UChar* d2 = rep2->characters16();
+
+ for (unsigned i = 0; i < size1; i++) {
+ if (d1[i] != d2[i])
+ return false;
+ }
+ return true;
+ }
+
+ if (s2Is8Bit) {
+ const UChar* d1 = rep1->characters16();
+ const LChar* d2 = rep2->characters8();
+
+ for (unsigned i = 0; i < size1; i++) {
+ if (d1[i] != d2[i])
+ return false;
+ }
+ return true;
+
+ }
+
+ const UChar* d1 = rep1->characters16();
+ const UChar* d2 = rep2->characters16();
+
+ if (d1 == d2) // Check to see if the data pointers are the same.
+ return true;
+
+ // Do quick checks for sizes 1 and 2.
+ switch (size1) {
+ case 1:
+ return d1[0] == d2[0];
+ case 2:
+ return (d1[0] == d2[0]) & (d1[1] == d2[1]);
+ default:
+ return (!memcmp(d1, d2, size1 * sizeof(UChar)));
+ }