Re: Speeding up XCode?
Re: Speeding up XCode?
- Subject: Re: Speeding up XCode?
- From: email@hidden
- Date: Mon, 24 Oct 2005 01:02:22 +1000
long long result = 0, intermediate, base = 10 /* Adapt to suit */;
unsigned int initialPosition, newPosition;
NSCharacterSet *decimalDigits = [NSCharacterSet
decimalDigitCharacterSet];
NSScanner *scanner = [NSScanner scannerWithString:myString];
//[scanner setCharactersToBeSkipped:[decimalDigits invertedSet]];
while (![scanner isAtEnd]) {
initialPosition = [scanner scanLocation];
if ([scanner scanLongLong:&intermediate]) {
newPosition = [scanner scanLocation];
while (initialPosition < newPosition) {
result *= base;
++initialPosition;
}
result += intermediate;
}
[scanner scanUpToCharactersFromSet:decimalDigits intoString:nil];
}
Dunno if it's fast, but it's accurate.
Apparently I lied. The call to NSScanner's setCharactersToBeSkipped
apparently needs to be removed for this to work. Thanks to Roger
(email@hidden) for pointing this out.
I don't understand why it makes a difference, though. Only if
scanLongLong skips characters during conversion (not just before)
would this conclusion make sense, which is exactly what the
documentation says it doesn't do.
Wade Tregaskis
ICQ: 40056898
AIM, Yahoo & Skype: wadetregaskis
MSN: email@hidden
iChat & email: email@hidden
Jabber: email@hidden
Google Talk: email@hidden
http://homepage.mac.com/wadetregaskis/
-- Sed quis custodiet ipsos custodes?
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden