|
nice hindsight!
|
|
|
|
|
You know what you might try, if the container is indexable (your code is way up top of the thread and I don't recall it offhand) is do the loops without the enumerator.
for(int i = 0; i < container.Count; ++i) { ...
Like that. My bet is your results will be more similar at that point, but if i had to guess which one would be faster, I still suspect the method call one will be faster due to the overhead of running loops.
To err is human. Fortune favors the monsters.
|
|
|
|
|
I'd argue that you really need two lists, one of Type[A] and one of Type[B] (sorry, couldn't figure out how to avoid font changes with the <>). This appears to really be an issue of delaying the decision until too deep in the code's decision trees. The new code is easier to read and it really points out that your list should be two lists.
|
|
|
|
|
To me, this is a clear case of premature optimization and (almost) every optimization is premature if it sacrifices clarity when the need for optimization has not be demonstrated. There are certain cases involving function calls that I know for a fact can be done better so I deal with those up front rather than later since the delta time spent is zero.
Here's an exmple : x*x is considerably faster than pow(x,2) so I deal with that up front instead of returning to it later. Especially since calling the pow function does not enhance clarity.
"They have a consciousness, they have a life, they have a soul! Damn you! Let the rabbits wear glasses! Save our brothers! Can I get an amen?"
|
|
|
|
|
I am not C# programmer, but I would prefer it was written in C. Overhead is easier to spot.
"A little time, a little trouble, your better day"
Badfinger
|
|
|
|
|
Performance is not the main reason to avoid multiple enumeration. Depending on the origin of the source, the collection may be changed between any two enumerations, so the result will be a bug that is extremely hard to reproduce.
|
|
|
|
|
Did you ever try to eat a clock?
It's time consuming, especially if you go back for seconds.
"A little time, a little trouble, your better day"
Badfinger
|
|
|
|
|
No, I couldn't face it.
[Sorry folks, I know I really shouldn't encourage him...]
|
|
|
|
|
Then I'll have to hand it to you if you can dial it back.
"A little time, a little trouble, your better day"
Badfinger
|
|
|
|
|
Ate a clock?
Isn’t that a little late for dinner?
If you can't laugh at yourself - ask me and I will do it for you.
|
|
|
|
|
Non-stop punishment!
"A little time, a little trouble, your better day"
Badfinger
|
|
|
|
|
Message Closed
modified 31-May-22 22:42pm.
|
|
|
|
|
This isn't a forum for programming questions. Please submit your question by mousing over "quick answers" under the site's banner and clicking on "Ask a Question".
|
|
|
|
|
|
How did your post become a reply to a more recent post? Is that what happens when a post is deleted?
Also the gray arrow that points to its parent points somewhere strange.
|
|
|
|
|
Glitch in matrix.
The message id of response in smaller than message id of question. Something was done on database perhaps.
"It is easy to decipher extraterrestrial signals after deciphering Javascript and VB6 themselves.", ISanti[ ^]
|
|
|
|
|
We've been here before...
Bugs and Suggestions[^]
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
Wordle 347 6/6
🟨⬜⬜🟨⬜
⬜🟨🟨🟨⬜
🟩🟨🟨⬜🟨
🟩🟩🟨⬜🟨
🟩🟩🟩🟩⬜
🟩🟩🟩🟩🟩
Just managed it.
|
|
|
|
|
That was close!
Wordle 347 6/6
⬜⬜⬜🟨🟨
🟨🟨🟨⬜⬜
⬜🟨🟨⬜🟨
🟩⬜🟩🟩🟨
🟩🟩🟩🟩⬜
🟩🟩🟩🟩🟩
I think your fifth guess was probably identical to mine ...
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
OriginalGriff wrote: I think your fifth guess was probably identical to mine
I think so too.
|
|
|
|
|
Yeah, I thought that ending was more obvious and likely as well ...
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Wordle 347 2/6
⬜🟩🟩🟩🟩
🟩🟩🟩🟩🟩
Sheer luck
Life should not be a journey to the grave with the intention of arriving safely in a pretty and well-preserved body, but rather to skid in broadside in a cloud of smoke, thoroughly used up, totally worn out, and loudly proclaiming “Wow! What a Ride!" - Hunter S Thompson - RIP
|
|
|
|
|
Wordle 347 6/6
🟨⬜⬜⬜⬜
🟨⬜⬜⬜🟨
🟨⬜⬜⬜⬜
⬜🟩🟩🟩⬜
🟩🟩🟩🟩⬜
🟩🟩🟩🟩🟩
Another identical fifth guess
|
|
|
|
|
This was straining.
Wordle 347 5/6*
⬛⬛⬛⬛🟨
🟨🟩⬛⬛⬛
⬛🟩🟨⬛⬛
⬛🟩🟩🟩🟩
🟩🟩🟩🟩🟩
"It is easy to decipher extraterrestrial signals after deciphering Javascript and VB6 themselves.", ISanti[ ^]
|
|
|
|
|
Wordle 347 5/6*
⬜🟩⬜🟩⬜
⬜🟩⬜🟩⬜
⬜🟩🟩🟩🟩
⬜🟩🟩🟩🟩
🟩🟩🟩🟩🟩
|
|
|
|