Issue 7487 - A faster std.bitmanip.BitArray.opCat
Summary: A faster std.bitmanip.BitArray.opCat
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P4 enhancement
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-02-12 11:42 UTC by bearophile_hugs
Modified: 2024-12-01 16:14 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description bearophile_hugs 2012-02-12 11:42:53 UTC
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.
Comment 1 SomeDude 2012-04-19 08:55:17 UTC
See also 7488 and 7490
Comment 2 dlangBugzillaToGithub 2024-12-01 16:14:51 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/phobos/issues/9922

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB