adium 5065:bdb891dbab1c: Two more OSAtomicCompareAndSwapPtrBarri...

commits at adium.im commits at adium.im
Thu Sep 13 09:19:41 UTC 2012


details:	http://hg.adium.im/adium/rev/bdb891dbab1c
revision:	5065:bdb891dbab1c
branch:		(none)
author:		Thijs Alkemade <thijsalkemade at gmail.com>
date:		Thu Sep 13 11:19:26 2012 +0200

Two more OSAtomicCompareAndSwapPtrBarrier are now a dispatch_once.

diffs (78 lines):

diff -r 7ec97d2e2160 -r bdb891dbab1c Plugins/Purple Service/CBPurpleOscarAccount.m
--- a/Plugins/Purple Service/CBPurpleOscarAccount.m	Thu Sep 13 11:16:24 2012 +0200
+++ b/Plugins/Purple Service/CBPurpleOscarAccount.m	Thu Sep 13 11:19:26 2012 +0200
@@ -455,41 +455,40 @@
 	NSAttributedString	*inAttributedString = inContentMessage.message;
 	NSString			*encodedString;
 	
-  static AIHTMLDecoder * encoderCloseFontTags = nil;
-  static AIHTMLDecoder * encoderGroupChat = nil;
-  
-  if(!(encoderCloseFontTags && encoderGroupChat)) {
-	AIHTMLDecoder *newEncoder = [[AIHTMLDecoder alloc] initWithHeaders:YES
-															  fontTags:YES
-														 closeFontTags:YES
-															 colorTags:YES
-															 styleTags:YES
-														encodeNonASCII:NO
-														  encodeSpaces:NO
-													 attachmentsAsText:NO
-											 onlyIncludeOutgoingImages:YES
-														simpleTagsOnly:NO
-														bodyBackground:NO
-												   allowJavascriptURLs:YES];
-	OSAtomicCompareAndSwapPtrBarrier(nil, (__bridge void*)newEncoder, (void *)&encoderCloseFontTags);
+	static AIHTMLDecoder * encoderCloseFontTags = nil;
+	static AIHTMLDecoder * encoderGroupChat = nil;
 	
-	newEncoder = [[AIHTMLDecoder alloc] initWithHeaders:NO
-											   fontTags:YES
-										  closeFontTags:NO
-											  colorTags:YES
-											  styleTags:YES
-										 encodeNonASCII:NO
-										   encodeSpaces:NO
-									  attachmentsAsText:YES
-							  onlyIncludeOutgoingImages:YES
-										 simpleTagsOnly:YES
-										 bodyBackground:NO
-									allowJavascriptURLs:YES];
-	OSAtomicCompareAndSwapPtrBarrier(nil, (__bridge void*)newEncoder, (void *)&encoderGroupChat);
-	
-	[encoderCloseFontTags setAllowAIMsubprofileLinks:YES];
-	[encoderGroupChat setAllowAIMsubprofileLinks:YES];
-  }
+	static dispatch_once_t onceToken;
+	dispatch_once(&onceToken, ^{
+		encoderCloseFontTags = [[AIHTMLDecoder alloc] initWithHeaders:YES
+															 fontTags:YES
+														closeFontTags:YES
+															colorTags:YES
+															styleTags:YES
+													   encodeNonASCII:NO
+														 encodeSpaces:NO
+													attachmentsAsText:NO
+											onlyIncludeOutgoingImages:YES
+													   simpleTagsOnly:NO
+													   bodyBackground:NO
+												  allowJavascriptURLs:YES];
+		encoderGroupChat = [[AIHTMLDecoder alloc] initWithHeaders:NO
+														 fontTags:YES
+													closeFontTags:NO
+														colorTags:YES
+														styleTags:YES
+												   encodeNonASCII:NO
+													 encodeSpaces:NO
+												attachmentsAsText:YES
+										onlyIncludeOutgoingImages:YES
+												   simpleTagsOnly:YES
+												   bodyBackground:NO
+											  allowJavascriptURLs:YES];
+		
+		
+		[encoderCloseFontTags setAllowAIMsubprofileLinks:YES];
+		[encoderGroupChat setAllowAIMsubprofileLinks:YES];
+	});
 	
 	if (inListObject) {
 		if (inContentMessage.chat.isSecure &&




More information about the commits mailing list