digitalmars.D.learn - bitfields comparison in opEquals
- Per =?UTF-8?B?Tm9yZGzDtnc=?= (21/21) Apr 26 2018 I have a struct with a mixin(bitfields) containing many small
I have a struct with a mixin(bitfields) containing many small bitfields. I also have a class member in the struct. And because I want the class member to compare by using `is` I need to define bool opEquals(const scope typeof(this) that) const safe pure nothrow nogc { return (this.data == that.data && this.context is that.context && // these are all bitfields members // TODO can we do this comparison in one go? this.lang == that.lang && this.pot == that.pot && this.manner == that.manner && this.senseNr == that.senseNr && this.hasUniquePot == that.hasUniquePot && this.isHashed == that.isHashed); } Is there a way to make the bitfields-comparsion in opEquals run faster by somehow checking for its size in words (n) and casting it to size_t[n] which can be compared very fast.
Apr 26 2018