News for hackers. Stuff that matters.
Re:What's wrong with this code, really? by qntm on Friday September 16, 2011 @09:04AM (#3004264)
What's wrong with the code, then, is that it was written under a little too much pressure for the developer to think clearly.

    for ( int i=0 ; i < this.MyControl.TabPages.Count ; )
    {
       this.MyControl.TabPages.Remove ( this.MyControl.TabPages[i] );
    }
Re:What's wrong with this code, really? by AlexandrB on Friday September 16, 2011 @09:14AM (#3004291)
Why not just:

  while (this.MyControl.TabPages.Count > 0)
  {
    this.MyControl.TabPages.Remove ( 0 );
  }
Re:What's wrong with this code, really? by qntm on Friday September 16, 2011 @12:08PM (#3005017)
Indeed. But the point I was making was that this hypothetical coder introduced more complexity by adding "i--;" whereas the code could equally well be fixed, in the same number of keystrokes, while reducing complexity, by removing "i++;".
Re:What's wrong with this code, really? by masklinn on Friday September 16, 2011 @09:35AM (#3004374)
Very inefficient on most array lists (but a very good idea on linked lists)
Re:What's wrong with this code, really? by tomjen3 on Friday September 16, 2011 @10:00AM (#3004460)
How many tabs do you use?

Less than 50?

Then don't worry about the optimization until you have to port it to a PDP10.

Re:What's wrong with this code, really? by masklinn on Friday September 16, 2011 @03:58PM (#3006038)
> Less than 50?

No, over nine thousands.

Re:What's wrong with this code, really? by masklinn on Friday September 16, 2011 @03:58PM (#3006037)
> Less than 50?

No, way more than that.

Re:What's wrong with this code, really? by tlrobinson on Friday September 16, 2011 @11:07AM (#3004721)

  while (this.MyControl.TabPages.Count > 0)
  {
    this.MyControl.TabPages.Remove ( this.MyControl.TabPages.Count-1 );
  }
Re:What's wrong with this code, really? by hasslblad on Friday September 16, 2011 @10:00AM (#3004459)
Or Even this.MyControl.TabPages.Clear();