aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorMax <post@wickenrode.com>2015-03-09 00:00:43 +0100
committerMax <post@wickenrode.com>2015-03-09 00:00:43 +0100
commit784876380b871b6d85978a705e2477e7b7d2d984 (patch)
tree5705e92b0aab9fecdf7d37954f5a0c3e873de1ff /Source
parentb15c7fb2d407ec8751a2579a7a68bbd8a037ccfe (diff)
downloadsequelpro-784876380b871b6d85978a705e2477e7b7d2d984.tar.gz
sequelpro-784876380b871b6d85978a705e2477e7b7d2d984.tar.bz2
sequelpro-784876380b871b6d85978a705e2477e7b7d2d984.zip
Minimal refactoring
Replaced some (range.location + range.length) with NSMaxRange(range)
Diffstat (limited to 'Source')
-rw-r--r--Source/SPCustomQuery.m2
-rw-r--r--Source/SPDataStorage.m6
-rw-r--r--Source/SPNarrowDownCompletion.m2
-rw-r--r--Source/SPQueryFavoriteManager.m4
-rw-r--r--Source/SPStringAdditions.m10
-rw-r--r--Source/SPTableData.m2
-rw-r--r--Source/SPTableStructure.m2
-rw-r--r--Source/SPTextView.m4
-rw-r--r--Source/SPTextViewAdditions.m10
9 files changed, 21 insertions, 21 deletions
diff --git a/Source/SPCustomQuery.m b/Source/SPCustomQuery.m
index 8b3897fe..70ff07ff 100644
--- a/Source/SPCustomQuery.m
+++ b/Source/SPCustomQuery.m
@@ -3152,7 +3152,7 @@
aRange = NSMakeRange(0,0);
NSInteger safeCnt = 0; // safety counter - not more than 200 loops allowed
while(1){
- aRange = [desc rangeOfRegex:@"\\s((https?|ftp|file)://.*?html)" options:RKLNoOptions inRange:NSMakeRange(aRange.location+aRange.length, [desc length]-aRange.location-aRange.length) capture:1 error:&err1];
+ aRange = [desc rangeOfRegex:@"\\s((https?|ftp|file)://.*?html)" options:RKLNoOptions inRange:NSMakeRange(NSMaxRange(aRange), [desc length]-aRange.location-aRange.length) capture:1 error:&err1];
if(aRange.location != NSNotFound) {
aUrl = [desc substringWithRange:aRange];
[desc replaceCharactersInRange:aRange withString:[NSString stringWithFormat:@"<a href='%@'>%@</a>", aUrl, aUrl]];
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];
diff --git a/Source/SPNarrowDownCompletion.m b/Source/SPNarrowDownCompletion.m
index d5391644..b9dba0e4 100644
--- a/Source/SPNarrowDownCompletion.m
+++ b/Source/SPNarrowDownCompletion.m
@@ -1025,7 +1025,7 @@
if (scanPosition + attributeResultRange.length == currentLength) break;
// A match was found - retrieve the location
- NSUInteger matchStart = attributeResultRange.location+attributeResultRange.length;
+ NSUInteger matchStart = NSMaxRange(attributeResultRange);
if ([[theView textStorage] attribute:kSPAutoCompletePlaceholderName atIndex:matchStart longestEffectiveRange:&attributeResultRange inRange:NSMakeRange(matchStart, currentLength - matchStart)]) {
[theView shouldChangeTextInRange:attributeResultRange replacementString:@""];
[[theView textStorage] deleteCharactersInRange:attributeResultRange];
diff --git a/Source/SPQueryFavoriteManager.m b/Source/SPQueryFavoriteManager.m
index 6522b884..a715bd93 100644
--- a/Source/SPQueryFavoriteManager.m
+++ b/Source/SPQueryFavoriteManager.m
@@ -413,7 +413,7 @@
// Check whether the selection range lies within the snippet
if (selRange.location != NSNotFound
&& selRange.location > matchedRange.location + 1
- && selRange.location + selRange.length < matchedRange.location + matchedRange.length)
+ && NSMaxRange(selRange) < NSMaxRange(matchedRange))
{
selectionInsideSnippet = YES;
}
@@ -423,7 +423,7 @@
NSInteger snippetNumber = [[queryString substringWithRange:snippetNumberRange] integerValue];
[snippetNumbers setObject:@YES forKey:[NSNumber numberWithInteger:snippetNumber]];
- rangeStart = matchedRange.location + matchedRange.length;
+ rangeStart = NSMaxRange(matchedRange);
}
// If the selection is not inside a snippet, wrap it inside the snippet syntax.
diff --git a/Source/SPStringAdditions.m b/Source/SPStringAdditions.m
index 0c623af7..0254dc36 100644
--- a/Source/SPStringAdditions.m
+++ b/Source/SPStringAdditions.m
@@ -322,7 +322,7 @@ static NSInteger _smallestOf(NSInteger a, NSInteger b, NSInteger c);
NSMutableArray *lineRangesArray = [NSMutableArray array];
// Check that the range supplied is valid - if not return an empty array.
- if (aRange.location == NSNotFound || aRange.location + aRange.length > [self length]) {
+ if (aRange.location == NSNotFound || NSMaxRange(aRange) > [self length]) {
return lineRangesArray;
}
@@ -332,9 +332,9 @@ static NSInteger _smallestOf(NSInteger a, NSInteger b, NSInteger c);
[lineRangesArray addObject:NSStringFromRange(currentLineRange)];
// Loop through until the line end matches or surpasses the end of the specified range
- while (currentLineRange.location + currentLineRange.length < aRange.location + aRange.length)
+ while (NSMaxRange(currentLineRange) < NSMaxRange(aRange))
{
- currentLineRange = [self lineRangeForRange:NSMakeRange(currentLineRange.location + currentLineRange.length, 0)];
+ currentLineRange = [self lineRangeForRange:NSMakeRange(NSMaxRange(currentLineRange), 0)];
[lineRangesArray addObject:NSStringFromRange(currentLineRange)];
}
@@ -502,7 +502,7 @@ static NSInteger _smallestOf(NSInteger a, NSInteger b, NSInteger c);
tmpMatchStore[matchCount] = found;
matchCount++;
//move the next search past the current match
- searchRange.location = found.location + found.length;
+ searchRange.location = NSMaxRange(found);
searchRange.length = [self length] - searchRange.location;
};
@@ -524,7 +524,7 @@ static NSInteger _smallestOf(NSInteger a, NSInteger b, NSInteger c);
NSRange prev = tmpMatchStore[mergeTarget];
NSRange this = tmpMatchStore[i];
//if the previous match ends right before this match begins we can merge them
- if(prev.location + prev.length == this.location) {
+ if(NSMaxRange(prev) == this.location) {
NSRange mergedRange = NSMakeRange(prev.location, prev.length+this.length);
tmpMatchStore[mergeTarget] = mergedRange;
}
diff --git a/Source/SPTableData.m b/Source/SPTableData.m
index 320a0b66..bdd1f1db 100644
--- a/Source/SPTableData.m
+++ b/Source/SPTableData.m
@@ -780,7 +780,7 @@
charsetDefinitionRange = [createTableParser rangeOfString:@"CHARACTER SET=" options:NSCaseInsensitiveSearch];
}
if (charsetDefinitionRange.location != NSNotFound) {
- stringStart = charsetDefinitionRange.location + charsetDefinitionRange.length;
+ stringStart = NSMaxRange(charsetDefinitionRange);
for (i = stringStart; i < [createTableParser length]; i++) {
if ([createTableParser characterAtIndex:i] == ' ') break;
}
diff --git a/Source/SPTableStructure.m b/Source/SPTableStructure.m
index 32739eb3..992ecdcf 100644
--- a/Source/SPTableStructure.m
+++ b/Source/SPTableStructure.m
@@ -912,7 +912,7 @@ static NSString *SPRemoveFieldAndForeignKey = @"SPRemoveFieldAndForeignKey";
// UNSIGNED keyword.
NSRange range = [queryString rangeOfString:[NSString stringWithFormat:@"%@ %@", [[theRow objectForKey:@"name"] backtickQuotedString], theRowType] options:NSLiteralSearch];
- NSInteger insertionIndex = (range.location + range.length);
+ NSInteger insertionIndex = NSMaxRange(range);
// If the field definition's data type includes the length then we must take this into
// account when inserting the UNSIGNED keyword. Add 2 to the index to accommodate the
diff --git a/Source/SPTextView.m b/Source/SPTextView.m
index f50ed939..12d6ed13 100644
--- a/Source/SPTextView.m
+++ b/Source/SPTextView.m
@@ -772,8 +772,8 @@ static inline NSPoint SPPointOnLine(NSPoint a, NSPoint b, CGFloat t) { return NS
backtickMode+=1;
leftBacktick = YES;
}
- if([[self string] length] > parseRange.location+parseRange.length) {
- if([[self string] characterAtIndex:parseRange.location+parseRange.length] == '`') {
+ if([[self string] length] > NSMaxRange(parseRange)) {
+ if([[self string] characterAtIndex:NSMaxRange(parseRange)] == '`') {
backtickMode+=2;
parseRange.length++; // adjust parse string for right `
rightBacktick = YES;
diff --git a/Source/SPTextViewAdditions.m b/Source/SPTextViewAdditions.m
index 7272de1d..56103a53 100644
--- a/Source/SPTextViewAdditions.m
+++ b/Source/SPTextViewAdditions.m
@@ -247,7 +247,7 @@
// if no selection place the caret at the end of the current word
{
NSRange newRange = [self getRangeForCurrentWord];
- [self setSelectedRange:NSMakeRange(newRange.location + newRange.length, 0)];
+ [self setSelectedRange:NSMakeRange(NSMaxRange(newRange), 0)];
}
}
@@ -269,7 +269,7 @@
// if no selection place the caret at the end of the current word
{
NSRange newRange = [self getRangeForCurrentWord];
- [self setSelectedRange:NSMakeRange(newRange.location + newRange.length, 0)];
+ [self setSelectedRange:NSMakeRange(NSMaxRange(newRange), 0)];
}
}
@@ -291,7 +291,7 @@
// if no selection place the caret at the end of the current word
{
NSRange newRange = [self getRangeForCurrentWord];
- [self setSelectedRange:NSMakeRange(newRange.location + newRange.length, 0)];
+ [self setSelectedRange:NSMakeRange(NSMaxRange(newRange), 0)];
}
}
@@ -312,7 +312,7 @@
// if no selection place the caret at the end of the current word
{
NSRange newRange = [self getRangeForCurrentWord];
- [self setSelectedRange:NSMakeRange(newRange.location + newRange.length, 0)];
+ [self setSelectedRange:NSMakeRange(NSMaxRange(newRange), 0)];
}
}
@@ -335,7 +335,7 @@
// if no selection place the caret at the end of the current word
{
NSRange newRange = [self getRangeForCurrentWord];
- [self setSelectedRange:NSMakeRange(newRange.location + newRange.length, 0)];
+ [self setSelectedRange:NSMakeRange(NSMaxRange(newRange), 0)];
}
}