• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Speeding up XCode?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
References: 
 >RE: Speeding up XCode? (From: Jeff Laing <email@hidden>)
 >Re: Speeding up XCode? (From: Robert Dell <email@hidden>)
 >Re: Speeding up XCode? (From: email@hidden)

  • Prev by Date: Re: "no source file named main.c"
  • Next by Date: -dylib_file
  • Previous by thread: Re: Speeding up XCode?
  • Next by thread: Re: Speeding up XCode?
  • Index(es):
    • Date
    • Thread