returns an effective deep copy of `routeConf`
(r routeConf)
| 98 | |
| 99 | // returns an effective deep copy of `routeConf` |
| 100 | func copyRouteConf(r routeConf) routeConf { |
| 101 | c := r |
| 102 | |
| 103 | if r.regexp.path != nil { |
| 104 | c.regexp.path = copyRouteRegexp(r.regexp.path) |
| 105 | } |
| 106 | |
| 107 | if r.regexp.host != nil { |
| 108 | c.regexp.host = copyRouteRegexp(r.regexp.host) |
| 109 | } |
| 110 | |
| 111 | c.regexp.queries = make([]*routeRegexp, 0, len(r.regexp.queries)) |
| 112 | for _, q := range r.regexp.queries { |
| 113 | c.regexp.queries = append(c.regexp.queries, copyRouteRegexp(q)) |
| 114 | } |
| 115 | |
| 116 | c.matchers = make([]matcher, len(r.matchers)) |
| 117 | copy(c.matchers, r.matchers) |
| 118 | |
| 119 | return c |
| 120 | } |
| 121 | |
| 122 | func copyRouteRegexp(r *routeRegexp) *routeRegexp { |
| 123 | c := *r |