develooper Front page | perl.perl6.users | Postings from June 2020

Re: Help converting CArray[uint8] to Blob

Thread Previous | Thread Next
From:
Ralph Mellor
Date:
June 16, 2020 23:09
Subject:
Re: Help converting CArray[uint8] to Blob
Message ID:
CAPLR5SfEK+E8MnZB1QseOTKg7J34p=VsBdJTi84Uuy3sndJyOw@mail.gmail.com
> my Data $ed = await $yenc_promise;

The promise must initialize each element of the CArray[uint]. It looks
pretty quick; I'm guessing it's low-level code doing that.

> my uint8 @data = $ed.data[0..$ed.data_size-1].Array;
> my Blob $bindata = Blob[uint8].new(@data);

Afaict that's a total of five HLL element-by-element copies.

I would expect this to work and be at least as fast and possibly a lot faster:

my Blob $bindata .= new: $ed.data;

hth

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About