Skip to content

Commit

Permalink
Replaced double allocation by a single one.
Browse files Browse the repository at this point in the history
  • Loading branch information
gfzabarino authored and kcharwood committed Jul 24, 2015
1 parent e06b051 commit b938c91
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions AFNetworking/AFURLSessionManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,13 @@ - (void)URLSession:(__unused NSURLSession *)session
__block NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
userInfo[AFNetworkingTaskDidCompleteResponseSerializerKey] = manager.responseSerializer;

NSData *data = nil;

if (self.downloadFileURL) {
userInfo[AFNetworkingTaskDidCompleteAssetPathKey] = self.downloadFileURL;
} else if (self.mutableData) {
userInfo[AFNetworkingTaskDidCompleteResponseDataKey] = [NSData dataWithData:self.mutableData];
data = [NSData dataWithData:self.mutableData];
userInfo[AFNetworkingTaskDidCompleteResponseDataKey] = data;
}

if (error) {
Expand All @@ -175,7 +178,7 @@ - (void)URLSession:(__unused NSURLSession *)session
} else {
dispatch_async(url_session_manager_processing_queue(), ^{
NSError *serializationError = nil;
responseObject = [manager.responseSerializer responseObjectForResponse:task.response data:[NSData dataWithData:self.mutableData] error:&serializationError];
responseObject = [manager.responseSerializer responseObjectForResponse:task.response data:data error:&serializationError];

if (self.downloadFileURL) {
responseObject = self.downloadFileURL;
Expand Down

0 comments on commit b938c91

Please sign in to comment.