diff options
author | Max <post@wickenrode.com> | 2015-03-09 00:00:43 +0100 |
---|---|---|
committer | Max <post@wickenrode.com> | 2015-03-09 00:00:43 +0100 |
commit | 784876380b871b6d85978a705e2477e7b7d2d984 (patch) | |
tree | 5705e92b0aab9fecdf7d37954f5a0c3e873de1ff /Frameworks/SPMySQLFramework | |
parent | b15c7fb2d407ec8751a2579a7a68bbd8a037ccfe (diff) | |
download | sequelpro-784876380b871b6d85978a705e2477e7b7d2d984.tar.gz sequelpro-784876380b871b6d85978a705e2477e7b7d2d984.tar.bz2 sequelpro-784876380b871b6d85978a705e2477e7b7d2d984.zip |
Minimal refactoring
Replaced some (range.location + range.length) with NSMaxRange(range)
Diffstat (limited to 'Frameworks/SPMySQLFramework')
-rw-r--r-- | Frameworks/SPMySQLFramework/Source/SPMySQLStreamingResultStore.m | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLStreamingResultStore.m b/Frameworks/SPMySQLFramework/Source/SPMySQLStreamingResultStore.m index 447cf19b..86a6b2b5 100644 --- a/Frameworks/SPMySQLFramework/Source/SPMySQLStreamingResultStore.m +++ b/Frameworks/SPMySQLFramework/Source/SPMySQLStreamingResultStore.m @@ -630,8 +630,8 @@ static inline void SPMySQLStreamingResultStoreFreeRowData(SPMySQLStreamingResult { // Throw an exception if the range is out of bounds - if (rangeToRemove.location + rangeToRemove.length > numberOfRows) { - [NSException raise:NSRangeException format:@"Requested storage index (%llu) beyond bounds (%llu)", (unsigned long long)(rangeToRemove.location + rangeToRemove.length), (unsigned long long)numberOfRows]; + if (NSMaxRange(rangeToRemove) > numberOfRows) { + [NSException raise:NSRangeException format:@"Requested storage index (%llu) beyond bounds (%llu)", (unsigned long long)(NSMaxRange(rangeToRemove)), (unsigned long long)numberOfRows]; } // Lock the data mutex @@ -639,14 +639,14 @@ static inline void SPMySQLStreamingResultStoreFreeRowData(SPMySQLStreamingResult // Free rows in the range NSUInteger i; - for (i = rangeToRemove.location; i < rangeToRemove.location + rangeToRemove.length; i++) { + for (i = rangeToRemove.location; i < NSMaxRange(rangeToRemove); i++) { SPMySQLStreamingResultStoreFreeRowData(dataStorage[i]); } numberOfRows -= rangeToRemove.length; // Renumber all subsequent indices to fill the gap size_t pointerSize = sizeof(SPMySQLStreamingResultStoreRowData *); - memmove(dataStorage + rangeToRemove.location, dataStorage + rangeToRemove.location + rangeToRemove.length, (numberOfRows - rangeToRemove.location) * pointerSize); + memmove(dataStorage + rangeToRemove.location, dataStorage + NSMaxRange(rangeToRemove), (numberOfRows - rangeToRemove.location) * pointerSize); // Unlock the mutex pthread_mutex_unlock(&dataLock); |