From 4ad26db45b46d8267fcb5203571b81bc8949b853 Mon Sep 17 00:00:00 2001 From: Max Date: Sat, 13 Dec 2014 03:01:19 +0100 Subject: Reformatting code for modern ObjC Replaced all [NSNumber numberWithBool:YES/NO] with the @YES/@NO literals. Also replaced some TRUE/FALSE with their YES/NO counterparts. --- Source/SPDataStorage.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Source/SPDataStorage.m') diff --git a/Source/SPDataStorage.m b/Source/SPDataStorage.m index ed50c7fc..30be0644 100644 --- a/Source/SPDataStorage.m +++ b/Source/SPDataStorage.m @@ -391,7 +391,7 @@ static inline NSMutableArray* SPDataStorageGetEditedRow(NSPointerArray* rowStore if (columnIndex >= numberOfColumns) { [NSException raise:NSRangeException format:@"Invalid column set as unloaded; requested column index (%llu) beyond bounds (%llu)", (unsigned long long)columnIndex, (unsigned long long)numberOfColumns]; } - unloadedColumns[columnIndex] = true; + unloadedColumns[columnIndex] = YES; } #pragma mark - Basic information -- cgit v1.2.3 From 2735e15bf5d4b3a976435ebb29ca9073de0e5071 Mon Sep 17 00:00:00 2001 From: Max Date: Sun, 4 Jan 2015 03:57:26 +0100 Subject: Formalize [x release], x = nil; convention Take this commit as a proposal to formalize our existing "[x release], x = nil;" convention by introducing a macro for it. Feel free to revert this commit if you see issues with the approch or implementation. --- Source/SPDataStorage.m | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'Source/SPDataStorage.m') diff --git a/Source/SPDataStorage.m b/Source/SPDataStorage.m index 30be0644..3db04159 100644 --- a/Source/SPDataStorage.m +++ b/Source/SPDataStorage.m @@ -58,7 +58,7 @@ static inline NSMutableArray* SPDataStorageGetEditedRow(NSPointerArray* rowStore { NSUInteger i; editedRowCount = 0; - [editedRows release], editedRows = nil; + SPClear(editedRows); if (unloadedColumns) free(unloadedColumns), unloadedColumns = NULL; if (dataStorage) { @@ -68,7 +68,7 @@ static inline NSMutableArray* SPDataStorageGetEditedRow(NSPointerArray* rowStore [newDataStorage replaceExistingResultStore:dataStorage]; } - [dataStorage release], dataStorage = nil; + SPClear(dataStorage); } dataStorage = [newDataStorage retain]; @@ -449,8 +449,8 @@ static inline NSMutableArray* SPDataStorageGetEditedRow(NSPointerArray* rowStore } - (void) dealloc { - [dataStorage release], dataStorage = nil; - [editedRows release], editedRows = nil; + SPClear(dataStorage); + SPClear(editedRows); if (unloadedColumns) free(unloadedColumns), unloadedColumns = NULL; [super dealloc]; -- cgit v1.2.3 From 784876380b871b6d85978a705e2477e7b7d2d984 Mon Sep 17 00:00:00 2001 From: Max Date: Mon, 9 Mar 2015 00:00:43 +0100 Subject: Minimal refactoring Replaced some (range.location + range.length) with NSMaxRange(range) --- Source/SPDataStorage.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Source/SPDataStorage.m') diff --git a/Source/SPDataStorage.m b/Source/SPDataStorage.m index 3db04159..dd5e87a5 100644 --- a/Source/SPDataStorage.m +++ b/Source/SPDataStorage.m @@ -357,12 +357,12 @@ static inline NSMutableArray* SPDataStorageGetEditedRow(NSPointerArray* rowStore { // Throw an exception if the range is out of bounds - if (rangeToRemove.location + rangeToRemove.length > SPMySQLResultStoreGetRowCount(dataStorage)) { - [NSException raise:NSRangeException format:@"Requested storage index (%llu) beyond bounds (%llu)", (unsigned long long)(rangeToRemove.location + rangeToRemove.length), SPMySQLResultStoreGetRowCount(dataStorage)]; + if (NSMaxRange(rangeToRemove) > SPMySQLResultStoreGetRowCount(dataStorage)) { + [NSException raise:NSRangeException format:@"Requested storage index (%llu) beyond bounds (%llu)", (unsigned long long)(NSMaxRange(rangeToRemove)), SPMySQLResultStoreGetRowCount(dataStorage)]; } // Remove the rows from the edited list and underlying storage - NSUInteger i = MIN(editedRowCount, rangeToRemove.location + rangeToRemove.length); + NSUInteger i = MIN(editedRowCount, NSMaxRange(rangeToRemove)); while (--i >= rangeToRemove.location) { editedRowCount--; [editedRows removePointerAtIndex:i]; -- cgit v1.2.3