Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 348837

Summary: OleAutomation: unnecessary call to objIDispatch.GetTypeInfo in constructors which may cause bad performance
Product: [Eclipse Project] Platform Reporter: Dominik ölzl <Dominik.Hoelzl>
Component: SWTAssignee: Platform-SWT-Inbox <platform-swt-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: minor    
Priority: P3 CC: manfred.schoeftner
Version: 3.6.2   
Target Milestone: ---   
Hardware: PC   
OS: Windows All   
Whiteboard: stalebug

Description Dominik ölzl CLA 2011-06-09 03:42:53 EDT
org.eclipse.swt.ole.win32.OleAutomation:

In all constructors objIDispatch.GetTypeInfo is called unnecessary .(objITypeInfo is only accessed in methods getHelpFile, getDocumentation, getPropertyDescription, getFunctionDescription, getTypeInfoAttributes and getNames which are all hardly ever used by SWT itself)

e.g.:

OleAutomation(IDispatch idispatch) {
	if (idispatch == null) OLE.error(OLE.ERROR_INVALID_INTERFACE_ADDRESS);
	objIDispatch = idispatch;
	objIDispatch.AddRef();
	
	int /*long*/[] ppv = new int /*long*/[1];
	/* GetTypeInfo([in] iTInfo, [in] lcid, [out] ppTInfo) 
	 * AddRef has already been called on ppTInfo by the callee and must be released by the caller. 
	 */
	int result = objIDispatch.GetTypeInfo(0, COM.LOCALE_USER_DEFAULT, ppv);
	if (result == OLE.S_OK) {
		objITypeInfo = new ITypeInfo(ppv[0]);
	}
}


In some cases, e.g. if calling Variant.getAutomation (which constructs a new OleAutomation instance) to an object representing an IE 9 document mode's IHTMLElement the call to GetTypeInfo costs more than one millisecond (intel i5) which causes a huge performance impact when dealing with many objects.


Solution/Workaround: Don't call GetTypeInfo in constructory but evaluate and store it when it's needed.
Comment 1 Eclipse Genie CLA 2020-01-12 20:13:30 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.