std.intrinsic
bearophile
bearophileHUGS at lycos.com
Wed Aug 13 09:41:02 PDT 2008
The functions of the std.intrinsic module (that I presume are often asm instructions) look nice, but time ago I have seen that normal D code is fasten than some of them:
You can see it from this code that use bt and btr:
http://shootout.alioth.debian.org/gp4/benchmark.php?test=nsievebits&lang=dlang&id=2
http://shootout.alioth.debian.org/gp4/benchmark.php?test=nsievebits&lang=dlang&id=1
The code that uses IsSet and Clear (functions originally coming from Pascal code) is faster:
bool IsSet(uint i) {
int offset = i / bpc;
uint mask = 1 << (i % bpc);
return (flags[offset] & mask) <> 0;
}
void Clear(uint i) {
int offset = i / bpc;
uint mask = 1 << (i % bpc);
if((flags[offset] & mask) <> 0)
flags[offset] = flags[offset] ^ mask;
}
So I can suggest to replace those functions of Phobos with functions in normal D code (such things are very useful to manage array of bits, that I use).
Bye,
bearophile
More information about the Digitalmars-d
mailing list