No: I'm suggesting exactly what I wrote.  Starting a goroutine looks like 
this:

go <function>(<args>)

It doesn't have to be an anonymous function, it can be a "real" function.  
Hence this is perfectly valid:

go BytesContainsCh1(b.Bytes(), start, end, find, ch)

On Sunday, 12 June 2022 at 18:17:23 UTC+2 Const V wrote:

> I already have a go routine on the anonymous function:
> go func(start, end, i int, quit chan string) {
>
> You are suggesting doing this?
> go func(start, end, i int, quit chan string) {
>       go BytesContainsCh1(b.Bytes(), start, end, find, ch)
>    }(start, end, i, quit)
>
> On Sunday, June 12, 2022 at 2:54:51 AM UTC-7 Brian Candler wrote:
>
>> On Sunday, 12 June 2022 at 09:16:30 UTC+1 Const V wrote:
>>
>>>   go func(start, end, i int, quit chan string) {
>>>       BytesContainsCh1(b.Bytes(), start, end, find, ch)
>>>    }(start, end, i, quit)
>>>
>>
>> I note that this could be further simplified to:
>>
>> go BytesContainsCh1(b.Bytes(), start, end, find, ch)
>>  
>> Maybe the compiler does this optimisation automatically.  Does it make 
>> any difference to your timings?
>>
>> If you want to understand the difference you might need to look at the 
>> assembly language generated. See what happens with the number of stack 
>> frames allocated, whether the unused argument 'i' is elided in one of the 
>> cases, and so on.
>>
>>>

-- 
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/1931ad2c-e806-4274-b45d-61259f7dc53bn%40googlegroups.com.

Reply via email to