Remove unnecessary null check in void SimplifyMarkupCommand::doApply().
authormacpherson@chromium.org <macpherson@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 10 Apr 2012 18:10:45 +0000 (18:10 +0000)
committermacpherson@chromium.org <macpherson@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 10 Apr 2012 18:10:45 +0000 (18:10 +0000)
https://bugs.webkit.org/show_bug.cgi?id=83535

Reviewed by Kentaro Hara.

No new tests / code cleanup only.

currentNode cannot be null within the loop body.
It is dereferenced before and after the removed line without checking.
Additionally I have added an assertion to express this loop invariant.

* editing/SimplifyMarkupCommand.cpp:
(WebCore::SimplifyMarkupCommand::doApply):

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

Source/WebCore/ChangeLog
Source/WebCore/editing/SimplifyMarkupCommand.cpp

index 8206a9f..39e5928 100644 (file)
@@ -1,3 +1,19 @@
+2012-04-10  Luke Macpherson  <macpherson@chromium.org>
+
+        Remove unnecessary null check in void SimplifyMarkupCommand::doApply().
+        https://bugs.webkit.org/show_bug.cgi?id=83535
+
+        Reviewed by Kentaro Hara.
+
+        No new tests / code cleanup only.
+
+        currentNode cannot be null within the loop body.
+        It is dereferenced before and after the removed line without checking.
+        Additionally I have added an assertion to express this loop invariant.
+
+        * editing/SimplifyMarkupCommand.cpp:
+        (WebCore::SimplifyMarkupCommand::doApply):
+
 2012-04-10  David Dorwin  <ddorwin@chromium.org>
 
         Add Encrypted Media Extensions methods to HTMLMediaElement
index e27fc2f..1239bdf 100644 (file)
@@ -62,10 +62,12 @@ void SimplifyMarkupCommand::doApply()
                 nodesToRemove.append(currentNode);
             
             currentNode = currentNode->parentNode();
+            ASSERT(currentNode);
+
             if (!currentNode->renderer() || !currentNode->renderer()->isRenderInline() || toRenderInline(currentNode->renderer())->alwaysCreateLineBoxes())
                 continue;
             
-            if (currentNode && currentNode->firstChild() != currentNode->lastChild()) {
+            if (currentNode->firstChild() != currentNode->lastChild()) {
                 topNodeWithStartingStyle = 0;
                 break;
             }