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

  • SEARCH
  • Home
  • 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 7194485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:22:55+00:00 2026-05-28T20:22:55+00:00

I am writing a program that is very critical to performance. I am polling

  • 0

I am writing a program that is very critical to performance. I am polling an atom feed that usually has about 50 entries. I need to parse through this can get the uri link as fast as possible.

Currently I am doing this:

var feedUrl = "my path";

using (var feedReader = XmlReader.Create(feedUrl))
{
    var feedContent = SyndicationFeed.Load(feedReader);
    if (null == feedContent) return null;

    foreach (var item in feedContent.Items.Reverse())
    {
        if (item.Title.Text.Contains("Some text I am looking for"))
        {
            foreach (var link in item.Links)
            {
                uri = link.Uri;
            }
        }
    }
}

Ive read from many sources that using a for loop is much faster than using foreach so I am trying to implement this but keep getting some errors that say cannot apply indexing to the SyndicationItem. This seems to be because SyndicationItem is an IEnumerable.

So this leaves me with two questions:
1.) Is there a better more efficient/faster way to do this
2.) Am I currently implementing the best solution?

  • 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-28T20:22:56+00:00Added an answer on May 28, 2026 at 8:22 pm

    The vast majority of time is likely getting spent in the round-trip to pick up the feed in the first place. Typically, network latency time will dwarf the amount of time it takes to iterate over a collection.

    However, it is possible that your feedContent.Items is not fully loaded into memory at once, and consequently iterating over the Reverse of this collection may cause a lot more overhead than you need. I’d personally suggest using a LINQ statement to grab the items you want in a single pass, then call .ToList() to put the results in an in-memory collection that is easily reversible before calling .Reverse().

    var uris = 
        (from item in feedContent.Items
        where item.Title.Text.Contains(searchTerm)
        from link in item.Links
        select link.Uri)
        .ToList()
        .Reverse();
    

    Or, if you’re just interested in a single URI (your code makes it look like you’re just trying to end up with the first URI in the first match), you might as well just call .FirstOrDefault() and skip the Reverse and ToList entirely:

    var uris = 
        (from item in feedContent.Items
        where item.Title.Text.Contains(searchTerm)
        from link in item.Links
        select link.Uri)
        .FirstOrDefault()
    

    Update

    I played with this a little and (as I suspected) roughly 95% of the cost of this program (testing against a feed with 25 items on Blogger) is taken up with the calls to XmlReader.Create() and SyndicationFeed.Load(). Trying to optimize the for loop is like measuring with a micrometer, marking with a wax pencil, and cutting with an axe.

    Update 2

    In response to your comment: Yes, there is a way, and it’s pretty simple, too.

    var updateTimesByUri = 
        (from item in feedContent.Items
        where item.Title.Text.Contains(searchTerm)
        from link in item.Links
        select new {link.Uri, item.LastUpdatedTime})
        .ToDictionary(l => l.Uri, l => l.LastUpdatedTime)
    

    And just to reiterate, this won’t give you any significant performance improvement, but the code is much more expressive of what you’re really trying to do, and therefore much easier to maintain.

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

Sidebar

Related Questions

I'm writing a program that essentially stores a series of scenarios. These scenarios need
I'm writing a ruby program that need raw cpu power (I know ruby is
I'm writing a program in c# for Windows7 that works very fine... But now
I'm writing a program which will need to do a very large number of
I am writing a program that uses the quickfix library. The documentation is very
I'm thinking about writing a program that asks the user to think of an
I need some help with a program that I am writing for my Systems
I am writing a program that could very much use __sync_fetch_and_add . Unfortunately my
I'm writing an iPhone program that has a login view controller that allows the
Im writing a program that should read input via stdin, so I have 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.