Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Performance: NSMutableString Vrs. raw char[ ] arrays

Performance: NSMutableString Vrs. raw char[ ] arrays
Thread Tools
Junior Member
Join Date: Aug 2002
Location: Northeastern NV, USA
Status: Offline
Reply With Quote
Nov 29, 2002, 10:39 AM
 
I think the answer to this one might be somewhat obvious...

If you're writing a Cocoa application that alters large groups (or blocks) of strings, will performance be better using NSMutableString (and the substring, range, delete and insert methods), or would I be better off converting the NSString data to char[ ] arrays, performing my manipulations, and then converting it back to NSString for final output?

I already have my functions written in C with character arrays, I'm porting them from the Windows environment. The one problem I see with the char[ ] array approach might be UniCode, however at this time I'm not that concerned with anything outside the bounds of standard ASCII characters. (But I might not want to lock my self into this situation either.)

I will be performing thousands of comparisions and replacements within my strings until an end result is achieved. I'd imagine that you would get better performance using raw C structures, but how do most people handle these types of operations when programming in Cocoa/Objective-C ?
     
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status: Offline
Reply With Quote
Nov 29, 2002, 01:16 PM
 
Obj-C will always have a higher overhead than raw C. you can take a look at the implementations of NSMutableString in CoreFoundation (NSMutableStrings are CFStrings), part of Darwin.
     
Junior Member
Join Date: Aug 2002
Location: Northeastern NV, USA
Status: Offline
Reply With Quote
Nov 30, 2002, 09:06 AM
 
Originally posted by Angus_D:
Obj-C will always have a higher overhead than raw C. you can take a look at the implementations of NSMutableString in CoreFoundation (NSMutableStrings are CFStrings), part of Darwin.
Thanks. I'll stick with my char[ ] arrays then. I'm probably going to regret it later (because of UniCode), but I'll cross that bridge when I get there...
     
Forum Regular
Join Date: Aug 2000
Location: UK
Status: Offline
Reply With Quote
Nov 30, 2002, 10:27 AM
 
Why don't you use unichar arrays? From NSString.h:

Code:
- (void)getCharacters:(unichar *)buffer; - (void)getCharacters:(unichar *)buffer range:(NSRange)aRange;
     
Junior Member
Join Date: Aug 2002
Location: Northeastern NV, USA
Status: Offline
Reply With Quote
Nov 30, 2002, 12:40 PM
 
Originally posted by calumr:
Why don't you use unichar arrays? From NSString.h:
Well... Uhhh....

Until you mentioned it I didn't even know they existed. Are they 16-bit versions of the old 8-bit char data type? I'll have to check 'em out!

Thanks!
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 06:24 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2