stonedauwg
stonedauwg

Reputation: 1407

NSMutableString appendString vs appendFormat, which is more efficient?

Given this:

NSString *innerXml = @"somevalue";
NSMutableString *xml = [[NSMutableString alloc] init];

Which of these is faster; not asking about readability, which is subjective:

1.

[xml appendFormat:@"<randomElement>%@</randomElement>", innerXml];

2.

[xml appendString:@"<randomElement>"];
[xml appendString:innerXml];
[xml appendString:@"</randomElement>"];

Upvotes: 2

Views: 652

Answers (1)

zaph
zaph

Reputation: 112857

If you are really curious about the implementation read the source code, it is available online, see: CFString.c.

Essentially the core foundation code is available as part of the opensourceing of the darwin kernel.

Upvotes: 1

Related Questions