@@ -9,11 +9,25 @@ import (
99 "strings"
1010 "time"
1111
12- "bitbucket.org/creachadair/stringset"
1312 glog "github.com/golang/glog"
1413)
1514
16- var selfLinkIgnorableComponents = stringset .New ("projects" , "regions" , "locations" , "zones" , "organizations" , "compute" , "v1" , "v1beta1" , "beta" )
15+ var selfLinkIgnorableComponents = map [string ]struct {}{
16+ "projects" : {},
17+ "regions" : {},
18+ "locations" : {},
19+ "zones" : {},
20+ "organizations" : {},
21+ "compute" : {},
22+ "v1" : {},
23+ "v1beta1" : {},
24+ "beta" : {},
25+ }
26+
27+ func hasKey (m map [string ]struct {}, k string ) bool {
28+ _ , ok := m [k ]
29+ return ok
30+ }
1731
1832// SelfLinkToSelfLink returns true if left and right are equivalent for selflinks.
1933// That means that they are piecewise equal, comparing components, allowing for
@@ -54,9 +68,9 @@ func SelfLinkToSelfLink(l, r *string) bool {
5468 case lcomp [li ] == rcomp [ri ]:
5569 li ++
5670 ri ++
57- case selfLinkIgnorableComponents . Contains ( lcomp [li ]):
71+ case hasKey ( selfLinkIgnorableComponents , lcomp [li ]):
5872 li ++
59- case selfLinkIgnorableComponents . Contains ( rcomp [ri ]):
73+ case hasKey ( selfLinkIgnorableComponents , rcomp [ri ]):
6074 ri ++
6175 // The second-to-last element in a long-form self-link contains the
6276 // name of the resource. The name of the resource might be anything,
@@ -192,9 +206,9 @@ func PartialSelfLinkToSelfLink(l, r *string) bool {
192206 case lcomp [li ] == rcomp [ri ]:
193207 li --
194208 ri --
195- case selfLinkIgnorableComponents . Contains ( lcomp [li ]):
209+ case hasKey ( selfLinkIgnorableComponents , lcomp [li ]):
196210 li --
197- case selfLinkIgnorableComponents . Contains ( rcomp [ri ]):
211+ case hasKey ( selfLinkIgnorableComponents , rcomp [ri ]):
198212 ri --
199213 // As in SelfLinkToSelfLink, we permit any value in the second-to-last field
200214 // for the value which is longer.
0 commit comments