Copilot commented on code in PR #3471:
URL: https://github.com/apache/dubbo-go/pull/3471#discussion_r3533880836


##########
common/config/environment.go:
##########
@@ -138,7 +138,7 @@ func (conf *InmemoryConfiguration) GetSubProperty(subKey 
string) map[string]stru
        conf.store.Range(func(key, _ any) bool {
                if idx := strings.Index(key.(string), subKey); idx >= 0 {
                        after := key.(string)[idx+len(subKey):]
-                       if i := strings.Index(after, "."); i >= 0 {
+                       if found := strings.Contains(after, "."); found {
                                properties[after[0:strings.Index(after, ".")]] 
= struct{}{}
                        }

Review Comment:
   `strings.Contains(after, ".")` followed by `strings.Index(after, ".")` scans 
the string twice. This is a small but avoidable performance regression compared 
to the previous single `Index` check, and it also makes the code slightly 
harder to read.



##########
remoting/exchange_test.go:
##########
@@ -42,9 +42,8 @@ func TestSequenceID(t *testing.T) {
 func TestSequenceIDConcurrent(t *testing.T) {
        var wg sync.WaitGroup
        ids := make(chan int64, 50)
-       for i := 0; i < 50; i++ {
-               wg.Add(1)
-               go func() { defer wg.Done(); ids <- SequenceID() }()
+       for range 50 {
+               wg.Go(func() { ; ids <- SequenceID() })

Review Comment:
   The blank statement (`;`) inside the goroutine body is unnecessary and hurts 
readability. The send expression is already a valid standalone statement.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to