Nope. Bound checks are still there. I am puzzled by this one.

On Fri, Feb 21, 2020 at 9:34 AM Sebastien Binet <bi...@cern.ch> wrote:

>
>
> On Fri, Feb 21, 2020 at 5:36 PM Bruno Albuquerque <b...@gmail.com> wrote:
>
>> I wrote some simple code to convert a RGB24 image represented as a []byte
>> to a NRGBA image (also as a []byte), like so:
>>
>> https://play.golang.org/p/Y7ICg7t4_nd
>>
>> Unfortunately, the performance is lacking here and I am trying to improve
>> it. The first low hanging fruit seems to be taking advantage of BCE:
>>
>> $go test -bench .
>> goos: linux
>> goarch: amd64
>> BenchmarkNRGBA-8       484   2636344 ns/op
>>
>> $ go test -gcflags="-B" -bench .
>> goos: linux
>> goarch: amd64
>> BenchmarkNRGBA-8       855   1654882 ns/op
>>
>> Unfortunately, I could not find an incantation that would remove the
>> bound checks. My naive attempt was to just do
>>
>> _ = nrgbaData[len(nrgbaData)-1]
>>
>> at around line 7 in the program above but this did not help and added one
>> extra bound check.
>>
>> Funny enough, if I do
>>
>> _ = nrgbaData[len(nrgbaData)]
>>
>> all the bound checks seem to be eliminated but, obviously, the program
>> panics at this line.
>>
> what about:
>    _ = nrgbaData[:len(nrgbaData)]
>
> does this also remove the bound checks?
>
> -s
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAEd86TwuyTSizRPLaFjDnD0sX7_L7Y472UQ-27noPsBN9yKQrw%40mail.gmail.com.

Reply via email to