simplify Sema::AddInstanceMethodToGlobalPool, no functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66016 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp
index 5927826..55b0d16 100644
--- a/lib/Sema/SemaDeclObjC.cpp
+++ b/lib/Sema/SemaDeclObjC.cpp
@@ -1032,25 +1032,23 @@
 }
 
 void Sema::AddInstanceMethodToGlobalPool(ObjCMethodDecl *Method) {
-  ObjCMethodList &FirstMethod = InstanceMethodPool[Method->getSelector()];
-  if (!FirstMethod.Method) {
+  ObjCMethodList &Entry = InstanceMethodPool[Method->getSelector()];
+  if (Entry.Method == 0) {
     // Haven't seen a method with this selector name yet - add it.
-    FirstMethod.Method = Method;
-    FirstMethod.Next = 0;
-  } else {
-    // We've seen a method with this name, now check the type signature(s).
-    bool match = MatchTwoMethodDeclarations(Method, FirstMethod.Method);
-    
-    for (ObjCMethodList *Next = FirstMethod.Next; !match && Next; 
-         Next = Next->Next)
-      match = MatchTwoMethodDeclarations(Method, Next->Method);
-      
-    if (!match) {
-      // We have a new signature for an existing method - add it.
-      // This is extremely rare. Only 1% of Cocoa selectors are "overloaded".
-      FirstMethod.Next = new ObjCMethodList(Method, FirstMethod.Next);;
-    }
+    Entry.Method = Method;
+    Entry.Next = 0;
+    return;
   }
+  
+  // We've seen a method with this name, see if we have already seen this type
+  // signature.
+  for (ObjCMethodList *List = &Entry; List; List = List->Next)
+    if (MatchTwoMethodDeclarations(Method, List->Method))
+      return;
+    
+  // We have a new signature for an existing method - add it.
+  // This is extremely rare. Only 1% of Cocoa selectors are "overloaded".
+  Entry.Next = new ObjCMethodList(Method, Entry.Next);
 }
 
 // FIXME: Finish implementing -Wno-strict-selector-match.