www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7487] New: A faster std.bitmanip.BitArray.opCat

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7487

           Summary: A faster std.bitmanip.BitArray.opCat
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc



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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 12 2012
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7487


SomeDude <lovelydear mailmetrash.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lovelydear mailmetrash.com



PDT ---
See also 7488 and 7490

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 19 2012