-
April 7th, 2010, 07:25 PM
#1
Form.Invalidate(...)
Does anyone have any idea which of these is more efficient?
Code:
List<Rectangle> rectangles;
//some code to build the list (up to 56 rectangles)
// (1) is this the quickest?
foreach (Rectangle rect in rectangles)
this.Invalidate(rect);
// (2) or is this?
Region region = new Region();
foreach (Rectangle rect in rectangles)
region.Union(rect);
this.Invalidate(region);
OR... is it dependent on too many other factors to make a judgement?
Incidentally, in my scenario, if I use the region (2) option, then I don't need to build the list of rectangles beforehand, I can just add them to the region as they are created. This is because either the List<Rectangle> or the Region is returned from another function and not actually created in the same routine as in my example above.
Last edited by rliq; April 7th, 2010 at 07:28 PM.
Rob
-
Ohhhhh.... Old McDonald was dyslexic, E O I O EEEEEEEEEE.......
-
April 7th, 2010, 09:58 PM
#2
Re: Form.Invalidate(...)
Test test test, that is the best way to determine these things. however, If I had to guess, I would assume that option A would be quickest due to the simplicity of handling rectangles as opposed to amorphous regions. Maintaining a collection of rectangles is trivial.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|