advanceByCombiningCharacterSequence() can be simplified
authormmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Jun 2014 23:32:31 +0000 (23:32 +0000)
committermmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Jun 2014 23:32:31 +0000 (23:32 +0000)
https://bugs.webkit.org/show_bug.cgi?id=133591

Reviewed by Dean Jackson.

Use U16_NEXT() because it already does what we're trying to do.

No new tests because there is no behavior change.

* platform/graphics/mac/ComplexTextController.cpp:
(WebCore::advanceByCombiningCharacterSequence):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@170402 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/mac/ComplexTextController.cpp

index 338b4f5..9676d1f 100644 (file)
@@ -1,3 +1,17 @@
+2014-06-24  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        advanceByCombiningCharacterSequence() can be simplified
+        https://bugs.webkit.org/show_bug.cgi?id=133591
+
+        Reviewed by Dean Jackson.
+
+        Use U16_NEXT() because it already does what we're trying to do.
+
+        No new tests because there is no behavior change.
+
+        * platform/graphics/mac/ComplexTextController.cpp:
+        (WebCore::advanceByCombiningCharacterSequence):
+
 2014-06-24  Brady Eidson  <beidson@apple.com>
 
         Enable GAMEPAD in the Mac build, but disabled at runtime.
index 42a971c..3cc44c2 100644 (file)
@@ -268,18 +268,12 @@ static bool advanceByCombiningCharacterSequence(const UChar*& iterator, const UC
 
     markCount = 0;
 
-    baseCharacter = *iterator++;
-
-    if (U16_IS_SURROGATE(baseCharacter)) {
-        if (!U16_IS_LEAD(baseCharacter))
-            return false;
-        if (iterator == end)
-            return false;
-        UChar trail = *iterator++;
-        if (!U16_IS_TRAIL(trail))
-            return false;
-        baseCharacter = U16_GET_SUPPLEMENTARY(baseCharacter, trail);
-    }
+    unsigned i = 0;
+    U16_NEXT(iterator, i, end - iterator, baseCharacter);
+    iterator = iterator + i;
+
+    if (U16_IS_SURROGATE(baseCharacter))
+        return false;
 
     // Consume marks.
     while (iterator < end) {