]> granicus.if.org Git - clang/commitdiff
simplify Sema::AddInstanceMethodToGlobalPool, no functionality change.
authorChris Lattner <sabre@nondot.org>
Wed, 4 Mar 2009 05:16:45 +0000 (05:16 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 4 Mar 2009 05:16:45 +0000 (05:16 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66016 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDeclObjC.cpp

index 59278267cd00d077cf2d60a9e587bfa95ab5ed84..55b0d16e8c48590ea2dda75493d80935ef363d05 100644 (file)
@@ -1032,25 +1032,23 @@ bool Sema::MatchTwoMethodDeclarations(const ObjCMethodDecl *Method,
 }
 
 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.