all: replace some cases of strings.SplitN with strings.Cut (#28446)
This commit is contained in:
+2
-2
@@ -86,8 +86,8 @@ func (msg *jsonrpcMessage) isUnsubscribe() bool {
|
||||
}
|
||||
|
||||
func (msg *jsonrpcMessage) namespace() string {
|
||||
elem := strings.SplitN(msg.Method, serviceMethodSeparator, 2)
|
||||
return elem[0]
|
||||
before, _, _ := strings.Cut(msg.Method, serviceMethodSeparator)
|
||||
return before
|
||||
}
|
||||
|
||||
func (msg *jsonrpcMessage) String() string {
|
||||
|
||||
+3
-3
@@ -93,13 +93,13 @@ func (r *serviceRegistry) registerName(name string, rcvr interface{}) error {
|
||||
|
||||
// callback returns the callback corresponding to the given RPC method name.
|
||||
func (r *serviceRegistry) callback(method string) *callback {
|
||||
elem := strings.SplitN(method, serviceMethodSeparator, 2)
|
||||
if len(elem) != 2 {
|
||||
before, after, found := strings.Cut(method, serviceMethodSeparator)
|
||||
if !found {
|
||||
return nil
|
||||
}
|
||||
r.mu.Lock()
|
||||
defer r.mu.Unlock()
|
||||
return r.services[elem[0]].callbacks[elem[1]]
|
||||
return r.services[before].callbacks[after]
|
||||
}
|
||||
|
||||
// subscription returns a subscription callback in the given service.
|
||||
|
||||
Reference in New Issue
Block a user