Page 1 of 1

Optimized Types - Oops Wrong Forum

Posted: Mon Jan 03, 2011 3:28 pm
by swhite
Hi

I read in a post recently that byte and word types were not optimized in PB. So my question is what are the optimized types in PB and what exactly is the difference between and optimized type and a non-optimized type.

Secondly I have been developing a PB wrapper for the Advantage Database Engine. I have slowing been converting ADS function calls to PB like the one shown below:
UNSIGNED32
AdsOpenTable (ADSHANDLE hConnect,UNSIGNED8 *pucName, UNSIGNED8 *pucAlias, UNSIGNED16 usTableType, UNSIGNED16 usCharType, UNSIGNED16 usLockType, UNSIGNED16 usCheckRights, UNSIGNED32 ulOptions, ADSHANDLE *phTable);

Code: Select all

AdsOpenTable(thConnect.i, tcTable.s, tcAlias.s, tnTableType.u, tnCharType.u, tnLockType.u, tnCheckRights.u, tnOptions.i, *thTable)
You will notice that I used the unicode type for the Unsigned16 parameters. Now I am wondering whether this is a mistake and I should be using some other type. So my question is how should mapping of types be done between PB and external libraries. Should I be concerned to match the number of bits or should I use an optimized type regardless of the number of bits? Any clarification would be appreciated.

Thanks,
Simon

Re: Optimized Types

Posted: Mon Jan 03, 2011 3:46 pm
by ts-soft
The quickest variable type is always that to whom the bit-wide of the OS corresponds. This counts to all computer languages! With other words: Integer in PureBasic.

Re: Optimized Types

Posted: Mon Jan 03, 2011 3:53 pm
by Thorium
ts-soft wrote:The quickest variable type is always that to whom the bit-wide of the OS corresponds. This counts to all computer languages! With other words: Integer in PureBasic.
This isnt entirely true.
Bytes are not slower on x86 and x64 CPU's than dwords or qwords. And dwords are not slower than qwords on x64 CPU's. PureBasic is optimized for integer type.

For CPU only words are very slow, because they are not optimized by Intel and AMD, because you dont need them often. They can be easiely replaced with dwords. Bytes are optimized by Intel and AMD because they are still needed.