I would think that because you have to access the list's index to assign it to the local variable in the first place, that it wouldn't be any faster.
18 Replies - 898 Views - Last Post: 17 January 2013 - 09:57 AM
#17
Re: how to use a text file as a database
Posted 17 January 2013 - 09:21 AM
Yeah, I was really dubious about the "5 times slower" comment. My thought of how that could be possible is that the IEnumerable implementation of the collection being iterated was really poorly written, and that each of the items being returned was an IDisposable.
This post has been edited by Skydiver: 17 January 2013 - 09:21 AM
#18
Re: how to use a text file as a database
Posted 17 January 2013 - 09:41 AM
Curtis Rutland, on 17 January 2013 - 10:19 AM, said:
I would think that because you have to access the list's index to assign it to the local variable in the first place, that it wouldn't be any faster.
Oh, yeah, good point. Maybe in situations where you access the item multiple times per iteration it might make a difference, albeit one several orders of magnitude smaller than we'd ever notice without asking the machine.
#19
Re: how to use a text file as a database
Posted 17 January 2013 - 09:57 AM
eclipsed4utoo, on 17 January 2013 - 06:12 AM, said:
A for loop is not 5 times faster. That would mean that if a foreach loop took 10 seconds to process a loop, then a for loop would take 2 seconds. For the most part, the performance difference is negligible. The only time I choose for over foreach is when I need the index.
I see, that's why I said "As I am aware..", thanks for clearing that up, and thanks for the guy who posted the test.
That's a thing I believe I read somewhere on the NET.
Sorry for giving incorrect info,
Have a nice day guys.
|
|

New Topic/Question
Reply




MultiQuote




|