AlexStocks commented on a change in pull request #708:
URL: https://github.com/apache/dubbo-go/pull/708#discussion_r475266561
##########
File path: common/url.go
##########
@@ -643,6 +643,34 @@ func (c *URL) CloneWithParams(reserveParams []string) *URL
{
)
}
+// IsEquals compares if two URLs equals with each other. Excludes are all
parameter keys which should ignored.
+func IsEquals(left URL, right URL, excludes ...string) bool {
+ if left.Ip != right.Ip || left.Port != right.Port {
+ return false
+ }
+
+ leftMap := left.ToMap()
+ rightMap := right.ToMap()
+ for _, exclude := range excludes {
+ delete(leftMap, exclude)
+ delete(rightMap, exclude)
+ }
+
+ if len(leftMap) != len(rightMap) {
+ return false
+ }
+
+ for lk, lv := range leftMap {
+ if rv, ok := rightMap[lk]; !ok {
+ return false
+ } else if lv != rv {
+ return false
+ }
+ }
Review comment:
the performance of reflection package is very low in go.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]