Revision: 13863
http://sourceforge.net/p/skim-app/code/13863
Author: hofman
Date: 2023-12-09 16:39:24 +0000 (Sat, 09 Dec 2023)
Log Message:
-----------
less confusing lazy creation of copy
Modified Paths:
--------------
trunk/NSString_SKExtensions.m
Modified: trunk/NSString_SKExtensions.m
===================================================================
--- trunk/NSString_SKExtensions.m 2023-12-09 16:25:40 UTC (rev 13862)
+++ trunk/NSString_SKExtensions.m 2023-12-09 16:39:24 UTC (rev 13863)
@@ -179,16 +179,17 @@
- (NSString *)stringByRemovingAliens {
// make a mutable copy only if needed
- CFMutableStringRef theString = (void *)self;
+ CFMutableStringRef theString = NULL;
+ CFStringRef cfSelf = (CFStringRef)self;
CFStringInlineBuffer inlineBuffer;
- CFIndex length = CFStringGetLength(theString);
+ CFIndex length = CFStringGetLength(cfSelf);
// use the current mutable string with the inline buffer, but make a new
mutable copy if needed
- CFStringInitInlineBuffer(theString, &inlineBuffer, CFRangeMake(0, length));
+ CFStringInitInlineBuffer(cfSelf, &inlineBuffer, CFRangeMake(0, length));
UniChar ch;
-#define DELETE_CHARACTERS(n)
do{if((void*)self==theString){theString=(void*)[[self mutableCopy]
autorelease];};CFStringDelete(theString, CFRangeMake(delIdx, n));} while(0)
+#define DELETE_CHARACTERS(n)
do{if(NULL==theString){theString=CFStringCreateMutable(NULL,
cfSelf);};CFStringDelete(theString, CFRangeMake(delIdx, n));} while(0)
// idx is current index into the inline buffer, and delIdx is current
index in the mutable string
CFIndex idx = 0, delIdx = 0;
@@ -229,7 +230,7 @@
idx++;
}
- return (id)theString;
+ return [(NSString *)theString autorelease] ?: self;
}
- (NSString *)stringByAppendingEllipsis;
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit