Optimized Types - Oops Wrong Forum

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
swhite
Enthusiast
Enthusiast
Posts: 790
Joined: Thu May 21, 2009 6:56 pm

Optimized Types - Oops Wrong Forum

Post 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
Last edited by swhite on Mon Jan 03, 2011 6:24 pm, edited 1 time in total.
Simon White
dCipher Computing
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Optimized Types

Post 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.
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
Thorium
Addict
Addict
Posts: 1305
Joined: Sat Aug 15, 2009 6:59 pm

Re: Optimized Types

Post 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.
Post Reply