From 6572cde6805d9779ead3cd159cd26de2f17d0378 Mon Sep 17 00:00:00 2001 From: Mattt Thompson Date: Thu, 15 Sep 2011 12:28:30 -0500 Subject: [PATCH] Minor code formatting for initial data capacity from expectedContentLength --- AFNetworking/AFHTTPRequestOperation.m | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/AFNetworking/AFHTTPRequestOperation.m b/AFNetworking/AFHTTPRequestOperation.m index 275aba0..6638ff8 100644 --- a/AFNetworking/AFHTTPRequestOperation.m +++ b/AFNetworking/AFHTTPRequestOperation.m @@ -23,7 +23,8 @@ #import "AFHTTPRequestOperation.h" #import "AFNetworkActivityIndicatorManager.h" -#define AFHTTPMinContentLength 1024 * 1024 * 8 +static NSUInteger const kAFHTTPMinimumInitialDataCapacity = 1024; +static NSUInteger const kAFHTTPMaximumInitialDataCapacity = 1024 * 1024 * 8; typedef enum { AFHTTPOperationReadyState = 1, @@ -303,11 +304,8 @@ didReceiveResponse:(NSURLResponse *)response if (self.outputStream) { [self.outputStream open]; } else { - NSUInteger contentLength = MAX(abs(response.expectedContentLength), 1024); - if (contentLength < AFHTTPMinContentLength) { - contentLength = AFHTTPMinContentLength; - } - self.dataAccumulator = [NSMutableData dataWithCapacity:contentLength]; + NSUInteger capacity = MIN(MAX(abs(response.expectedContentLength), kAFHTTPMinimumInitialDataCapacity), kAFHTTPMaximumInitialDataCapacity); + self.dataAccumulator = [NSMutableData dataWithCapacity:capacity]; } }