Project: SWT
Bug 87279 6 different methods cause pens to be constructed and selected
Reported: 2005-03-07 11:17:12 | Status: resolved fixed

There are 6 different methods on GC which result in a call to setPen(), which constructs and selects a Pen. This does not reflect the behavior of native C programs which would construct the proper Pen the first time, without intermediate, unused Pens. GC should only construct Pens which are actually needed, tracking the intermediate state locally until pen creation occurs. I haven't benchmarked anything yet, so I'd be willing to run some profiling of extpen creation overhead. An alternative is to add some setAll() method which takes all paremeters at once.

Files changed in fix:
bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GCData.java bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Path.java bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/TextLayout.java bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Canvas.java