Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A faster std.bitmanip.BitArray.opCat #9922

Open
dlangBugzillaToGithub opened this issue Feb 12, 2012 · 1 comment
Open

A faster std.bitmanip.BitArray.opCat #9922

dlangBugzillaToGithub opened this issue Feb 12, 2012 · 1 comment

Comments

@dlangBugzillaToGithub
Copy link

bearophile_hugs reported this on 2012-02-12T11:42:53Z

Transfered from https://issues.dlang.org/show_bug.cgi?id=7487

CC List

  • lovelydear

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.
@dlangBugzillaToGithub
Copy link
Author

lovelydear commented on 2012-04-19T08:55:17Z

See also 7488 and 7490

@LightBender LightBender removed the P4 label Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants