From 869b122a153b07e8c34b0247d107cb1d501d0c69 Mon Sep 17 00:00:00 2001 From: Jonathan Schleifer Date: Thu, 14 Feb 2013 00:18:20 +0100 Subject: [PATCH] Don't cache the description of exceptions. This was pretty pointless, as it's usually only used once. --- src/XMPPExceptions.m | 52 ++++++++++---------------------------------- 1 file changed, 12 insertions(+), 40 deletions(-) diff --git a/src/XMPPExceptions.m b/src/XMPPExceptions.m index be2713b..5a73eb8 100644 --- a/src/XMPPExceptions.m +++ b/src/XMPPExceptions.m @@ -65,17 +65,6 @@ [super dealloc]; } -- (OFString*)description -{ - if (_description != nil) - return _description; - - _description = [[OFString alloc] initWithFormat: - @"An exception occurred in class %@!", _inClass]; - - return _description; -} - - (XMPPConnection*)connection { return _connection; @@ -132,13 +121,9 @@ - (OFString*)description { - if (_description != nil) - return _description; - - _description = [[OFString alloc] initWithFormat: - @"Got stream error: %@. Reason: %@!", condition, reason]; - - return _description; + return [OFString stringWithFormat: + @"Got stream error in class %@: %@. Reason: %@!", [self inClass], + condition, reason]; } - (OFString*)condition @@ -202,14 +187,9 @@ - (OFString*)description { - if (_description != nil) - return _description; - - _description = [[OFString alloc] initWithFormat: - @"Stringprep with profile %@ failed on string '%@'!", - profile, string]; - - return _description; + return [OFString stringWithFormat: + @"Stringprep with profile %@ failed in class %@ on string '%@'!", + profile, [self inClass], string]; } - (OFString*)profile @@ -273,13 +253,9 @@ - (OFString*)description { - if (_description != nil) - return _description; - - _description = [[OFString alloc] initWithFormat: - @"IDNA operation %@ failed on string '%@'!", operation, string]; - - return _description; + return [OFString stringWithFormat: + @"IDNA operation %@ failed in class %@ on string '%@'!", operation, + [self inClass], string]; } - (OFString*)operation @@ -338,13 +314,9 @@ - (OFString*)description { - if (_description != nil) - return _description; - - _description = [[OFString alloc] initWithFormat: - @"Authentication failed. Reason: %@!", reason]; - - return _description; + return [OFString stringWithFormat: + @"Authentication failed in class %@. Reason: %@!", [self inClass], + reason]; } - (OFString*)reason