You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This implements an operator on std.bitmanip.BitArray, to append one or more bits at the beginning:
BitArray opCatAssign(BitArray b)
{
auto istart = len;
length = len + b.length;
for (auto i = istart; i < len; i++)
this[i] = b[i - istart];
return this;
}
BitArray opCat_r(bool b)
{
BitArray r;
r.length = len + 1;r[0] = b;for (size_t i = 0; i < len; i++) r[1 + i] = this[i];return r;
}
I think there are faster ways to perform those operations, that avoid copying single bits, and work mostly with a memmove() on the array of size_t pointed by BitArray.ptr (followed by few single bit copies if necessary).
In my code I have found that opCat_r() to be slow.
The text was updated successfully, but these errors were encountered:
bearophile_hugs reported this on 2012-02-12T11:42:53Z
Transfered from https://issues.dlang.org/show_bug.cgi?id=7487
CC List
Description
This implements an operator on std.bitmanip.BitArray, to append one or more bits at the beginning: BitArray opCatAssign(BitArray b) { auto istart = len; length = len + b.length; for (auto i = istart; i < len; i++) this[i] = b[i - istart]; return this; } BitArray opCat_r(bool b) { BitArray r; r.length = len + 1; r[0] = b; for (size_t i = 0; i < len; i++) r[1 + i] = this[i]; return r; } I think there are faster ways to perform those operations, that avoid copying single bits, and work mostly with a memmove() on the array of size_t pointed by BitArray.ptr (followed by few single bit copies if necessary). In my code I have found that opCat_r() to be slow.The text was updated successfully, but these errors were encountered: