Commit 78cc79a0 authored by Andrea Zoli's avatar Andrea Zoli
Browse files

ByteStream use memcpy instead of a loop to copy buffers.

parent aff9f9f6
Loading
Loading
Loading
Loading
+15 −27
Original line number Diff line number Diff line
@@ -81,7 +81,6 @@ PacketLib::ByteStream::ByteStream(ByteStreamPtr b0, ByteStreamPtr b1, ByteStream
    mem_allocation_constructor = true;

    /// Streams are swapped
    dword i = 0;
    dword dim = 0;
    if(b0 == 0 && b1 == 0 && b2 == 0)
    {
@@ -98,29 +97,18 @@ PacketLib::ByteStream::ByteStream(ByteStreamPtr b0, ByteStreamPtr b1, ByteStream
    this->bigendian = (b0!=0?b0->isBigendian():(b1!=0?b1->isBigendian():(b2!=0?b2->isBigendian():false)));
	if(b0 != 0)
	{
        dim = b0->getDimension();
        for(; i<b0->getDimension(); i++)
            stream[i] = b0->stream[i];
		memcpy(stream, b0->stream, b0->getDimension());
		dim += b0->getDimension();
	}
	if(b1 != 0)
	{
		memcpy(stream+dim, b1->stream, b1->getDimension());
		dim += b1->getDimension();
        dword istart = i;
        for(; i<dim; i++)
        {
            dword pos = i-istart;
            stream[i] = b1->stream[pos];
        }
	}
	if(b2 != 0)
	{
		memcpy(stream+dim, b2->stream, b2->getDimension());
		dim += b2->getDimension();
        dword istart = i;
        for(; i<dim; i++)
        {
            dword pos = i-istart;
            stream[i] = b2->stream[pos];
        }
	}
    setMemoryAllocated(true);
    mem_allocation_constructor = false;