Fastest way to convert from a Buf to a Str? #2

Hi All,

I need to read a file into a buffer (NO CONVERSIONS!)
and then convert it to a string (again with no
conversions).

I have been doing this:

    for ( @$BinaryFile ) -> $Char { $StrFile ~= chr($Char); }

But it takes a bit of time.  What is the fastest way to do this?

I guess there is not a way to create/declare a variable that is
both Buf and Str at the same time?  That would mean I did not
have to convert anything.  I use to get away with this under
Module 2 all the time.

$ p6 'my $B = Buf.new(0x66, 0x66, 0x77); $B.Str ~= "z";'
Cannot use a Buf as a string, but you called the Str method on it
   in block <unit> at -e line 1

$ p6 'my $B = Buf.new(0x66, 0x66, 0x77); Str($B) ~= "z";'
Cannot use a Buf as a string, but you called the Str method on it
   in block <unit> at -e line 1


Many thanks,
-T

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
A computer without Microsoft is like
a chocolate cake without the mustard
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0
perl6
2/3/2019 3:22:57 AM
perl.perl6.users 1146 articles. 0 followers. Follow

0 Replies
11 Views

Similar Articles

[PageSpeed] 22

Reply: