Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Reverting to less confusing “-patch_deepCopy:”.

  • Loading branch information...
commit 55af412b749430cdd8321dcd78367e2016f29a40 1 parent e9e9077
@JanX2 authored
Showing with 11 additions and 4 deletions.
  1. +8 −1 DiffMatchPatch.h
  2. +3 −3 DiffMatchPatch.m
View
9 DiffMatchPatch.h
@@ -85,6 +85,13 @@ typedef enum {
@end
+#ifndef NS_RETURNS_RETAINED
+#if __has_feature(attribute_ns_returns_retained)
+#define NS_RETURNS_RETAINED __attribute__((ns_returns_retained))
+#else
+#define NS_RETURNS_RETAINED
+#endif
+#endif
/*
* Class containing the diff, match and patch methods.
@@ -148,7 +155,7 @@ typedef enum {
- (NSMutableArray *)patch_makeFromDiffs:(NSMutableArray *)diffs;
- (NSMutableArray *)patch_makeFromOldString:(NSString *)text1 newString:(NSString *)text2 diffs:(NSMutableArray *)diffs;
- (NSMutableArray *)patch_makeFromOldString:(NSString *)text1 andDiffs:(NSMutableArray *)diffs;
-- (NSMutableArray *)patch_deepCopiedPatches:(NSArray *)patches; // Copy rule applies!
+- (NSMutableArray *)patch_deepCopy:(NSArray *)patches NS_RETURNS_RETAINED; // Copy rule applies!
- (NSArray *)patch_apply:(NSArray *)sourcePatches toString:(NSString *)text;
- (NSString *)patch_addPadding:(NSMutableArray *)patches;
- (void)patch_splitMax:(NSMutableArray *)patches;
View
6 DiffMatchPatch.m
@@ -2258,10 +2258,10 @@ - (NSMutableArray *)patch_makeFromOldString:(NSString *)text1
* @param patches NSArray of Patch objects.
* @return NSMutableArray of Patch objects.
*/
-- (NSMutableArray *)patch_deepCopiedPatches:(NSArray *)patches;
+- (NSMutableArray *)patch_deepCopy:(NSArray *)patches;
{
NSMutableArray *patchesCopy = [[NSMutableArray alloc] initWithArray:patches copyItems:YES];
- return [patchesCopy autorelease];
+ return patchesCopy;
}
/**
@@ -2280,7 +2280,7 @@ - (NSArray *)patch_apply:(NSArray *)sourcePatches
}
// Deep copy the patches so that no changes are made to originals.
- NSMutableArray *patches = [self patch_deepCopiedPatches:sourcePatches];
+ NSMutableArray *patches = [[self patch_deepCopy:sourcePatches] autorelease];
NSMutableString *textMutable = [[text mutableCopy] autorelease];

0 comments on commit 55af412

Please sign in to comment.
Something went wrong with that request. Please try again.