Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 766003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T16:58:34+00:00 2026-05-14T16:58:34+00:00

I am currently writing an XML parser that parses a lot of data, with

  • 0

I am currently writing an XML parser that parses a lot of data, with a lot of different nodes (the XML isn’t designed by me, and I have no control over the content…)

Anyway, it currently takes an unacceptably long time to download and read in (about 13 seconds) and so I’m looking for ways to increase the efficiency of the read.

I’ve written a function to create hash values, so that the program no longer has to do a lot of string comparison (just NSUInteger comparison), but this still isn’t reducing the complexity of the read in…

So I thought maybe I could create an array of IMPs so that, I could then go something like:

for(int i = 0; i < [hashValues count]; i ++)
{
    if(currHash == [[hashValues objectAtIndex:i] unsignedIntValue])
    {
        [impArray objectAtIndex:i];
    }   
}

Or something like that.

The only problem is that I don’t know how to actually make the call to the IMP function?

I’ve read that I perform the selector that an IMP defines by going

IMP tImp = [impArray objectAtIndex:i];
tImp(self, @selector(methodName));

But, if I need to know the name of the selector anyway, what’s the point?

Can anybody help me out with what I want to do? Or even just some more ways to increase the efficiency of the parser…

Here are some excerpts from my NSXMLParser Delegate:
From didStartElement

if([elementName isEqualToString:@"playingFilmData"])
{
    appDelegate.arrPlayingFilms = [[NSMutableArray alloc] init];
appDelegate.arrSessionTimes_ByFilm = [[NSMutableArray alloc] init];
appDelegate.arrSessionTimes_ByCinema = [[NSMutableArray alloc] init];
[self releaseData];
return;
}
else if([elementName isEqualToString:@"film_sessions"])
{
    aFilm.arrSessions = [[NSMutableArray alloc] init];
    [self releaseData];
    return;
}
else if([elementName isEqualToString:@"session"])
{
    aSession = [[ATM_SessionObject alloc] init];
    aSession.session_filmID = aFilm.film_id;
    [self releaseData];
    return;
}
else if([elementName isEqualToString:@"sess"])
{
    aFilm.arrSessions = [[NSMutableArray alloc] init];
    [self releaseData];
    return;
}
else if([elementName isEqualToString:@"cin"])
{
    cinID = [attributeDict objectForKey:@"id"];
    [self releaseData];
    return;
}
else if([elementName isEqualToString:@"s"])
{
    aSession = [[ATM_SessionObject alloc] init];
    aSession.session_filmID = aFilm.film_id;
    aSession.session_cinemaID = cinID;
    [self releaseData];
    return;
}
else if([elementName isEqualToString:@"flm"])
{
    aFilm = [[ATM_FilmObject alloc] init];
    aFilm.film_id = [attributeDict objectForKey:@"id"];
    aFilm.film_epNum = 0;

    [self releaseData];
    return;
}

[self releaseData];

From didEndElement

/*
 *0 = nowShowing_lastUpdate
 *1 = s
 *2 = tit
 *3 = des
 *4 = rate
 *5 = dir
 *6 = act
 *7 = rel
 *8 = flm
 */

NSUInteger numHash = [appDelegate murmerHashKey:elementName WithLegth:[elementName length] AndSeed:42];

if(currentElementValue)
{
if(numHash == [[hashValues objectAtIndex:0] unsignedIntValue])
{
    appDelegate.strNowShowingUpdate = currentElementValue;

    self releaseData];
    return;
}
else if(numHash == [[hashValues objectAtIndex:1] unsignedIntValue])
{
    [aFilm.arrSessions addObject:aSession];
    [appDelegate.arrSessionTimes_ByFilm addObject:aSession];

    [aSession release];
    aSession = nil;
}
else if(numHash == [[hashValues objectAtIndex:2] unsignedIntValue])
{
    [aFilm setValue:currentElementValue forKey:@"film_title"];

    [self releaseData];
    return;
}
else if(numHash == [[hashValues objectAtIndex:3] unsignedIntValue])
{
    [aFilm setValue:currentElementValue forKey:@"film_description"];

    [self releaseData];
    return;
}
else if(numHash == [[hashValues objectAtIndex:4] unsignedIntValue])
{
    [aFilm setValue:currentElementValue forKey:@"film_rating"];

    [self releaseData];
    return;
}
else if(numHash == [[hashValues objectAtIndex:5] unsignedIntValue])
{
    [aFilm setValue:currentElementValue forKey:@"film_directors"];

    [self releaseData];
    return;
}
else if(numHash == [[hashValues objectAtIndex:6] unsignedIntValue])
{
    [aFilm setValue:currentElementValue forKey:@"film_actors"];

    [self releaseData];
    return;
}               
}

if(numHash == [[hashValues objectAtIndex:8] unsignedIntValue])
{
[appDelegate.arrPlayingFilms addObject:aFilm];

[aFilm release];
aFilm = nil;

[self releaseData];
return;
}

[self releaseData];

I hope this helps shed some more light on what I’m doing wrong. Like I said, I’m new to this area of programming (and really, I’m actually a mathematician, not a programmer by training…), so I’m really super enthusiastic to learn not what to do!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T16:58:35+00:00Added an answer on May 14, 2026 at 4:58 pm

    You’re micro-optimizing without giving an overview of what the whole problem is about.

    Are you scanning (SAX) the XML or traversing a DOM structure? Are there memory issues? Even when SAX-parsing XML and you have no NSAutoreleasePools in place, you could allocate a lot of memory.

    I don’t believe that objc method dispatching is the source of your performance problem. You should use Shark to identify the bottleneck. The parsing itself surely is not the problem: The linked 1,4MB XML file takes 0.1 sec to run through xmllint -format

    If you want more help, you’ve got to describe more of what you’re doing: type of parser, what data or objects are you producing, more code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently writing a PowerShell script that parses an XML file, and it
I'm currently writing out xml and have done the following: header (content-type: text/xml); header
I'm currently writing a tool that parses the FxCop logfile on a large codebase.
I am writing a crawler/parser that should be able to process different types of
At the office we are currently writing an application that will generate XML files
I am currently writing a program using Weka that builds a model (using one
I'm currently writing a simple app that performs a series of requests to the
I am currently writing a simple IOS app that saves tasks into a table.
I'm currently writing a Powershell script that's used to select a user from Active
I am currently writing a Java compiler and have implemented section 15.12.2.7. of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.