Skip to content
This repository
Browse code

Adding isEqualToJID method to XMPPJID

  • Loading branch information...
commit 1554ff4567e4268d27400e0909fc5f2923ed5deb 1 parent ef1ff81
Robbie Hanson authored August 10, 2011
5  Core/XMPPJID.h
@@ -30,4 +30,9 @@
30 30
 
31 31
 - (BOOL)isServer;
32 32
 
  33
+/**
  34
+ * When you know both objects are JIDs, this method is a faster way to check equality than isEqual:.
  35
+**/
  36
+- (BOOL)isEqualToJID:(XMPPJID *)aJID; 
  37
+
33 38
 @end
53  Core/XMPPJID.m
@@ -355,34 +355,39 @@ - (BOOL)isEqual:(id)anObject
355 355
 {
356 356
 	if ([anObject isMemberOfClass:[self class]])
357 357
 	{
358  
-		XMPPJID *aJID = (XMPPJID *)anObject;
359  
-		
360  
-		if (user) {
361  
-			if (![user isEqualToString:aJID->user]) return NO;
362  
-		}
363  
-		else {
364  
-			if (aJID->user) return NO;
365  
-		}
366  
-		
367  
-		if (domain) {
368  
-			if (![domain isEqualToString:aJID->domain]) return NO;
369  
-		}
370  
-		else {
371  
-			if (aJID->domain) return NO;
372  
-		}
373  
-		
374  
-		if (resource) {
375  
-			if (![resource isEqualToString:aJID->resource]) return NO;
376  
-		}
377  
-		else {
378  
-			if (aJID->resource) return NO;
379  
-		}
380  
-		
381  
-		return YES;
  358
+		return [self isEqualToJID:(XMPPJID *)anObject];
382 359
 	}
383 360
 	return NO;
384 361
 }
385 362
 
  363
+- (BOOL)isEqualToJID:(XMPPJID *)aJID
  364
+{
  365
+	if (aJID == nil) return NO;
  366
+	
  367
+	if (user) {
  368
+		if (![user isEqualToString:aJID->user]) return NO;
  369
+	}
  370
+	else {
  371
+		if (aJID->user) return NO;
  372
+	}
  373
+	
  374
+	if (domain) {
  375
+		if (![domain isEqualToString:aJID->domain]) return NO;
  376
+	}
  377
+	else {
  378
+		if (aJID->domain) return NO;
  379
+	}
  380
+	
  381
+	if (resource) {
  382
+		if (![resource isEqualToString:aJID->resource]) return NO;
  383
+	}
  384
+	else {
  385
+		if (aJID->resource) return NO;
  386
+	}
  387
+	
  388
+	return YES;
  389
+}
  390
+
386 391
 - (NSString *)description
387 392
 {
388 393
 	return [self full];

0 notes on commit 1554ff4

Please sign in to comment.
Something went wrong with that request. Please try again.