JoinHandlers returns a copy of "h1" and "h2" Handlers slice joined as one slice of Handlers.
(h1 Handlers, h2 Handlers)
| 349 | |
| 350 | // JoinHandlers returns a copy of "h1" and "h2" Handlers slice joined as one slice of Handlers. |
| 351 | func JoinHandlers(h1 Handlers, h2 Handlers) Handlers { |
| 352 | if len(h1) == 0 { |
| 353 | return h2 |
| 354 | } |
| 355 | |
| 356 | if len(h2) == 0 { |
| 357 | return h1 |
| 358 | } |
| 359 | |
| 360 | nowLen := len(h1) |
| 361 | totalLen := nowLen + len(h2) |
| 362 | // create a new slice of Handlers in order to merge the "h1" and "h2" |
| 363 | newHandlers := make(Handlers, totalLen) |
| 364 | // copy the already Handlers to the just created |
| 365 | copy(newHandlers, h1) |
| 366 | // start from there we finish, and store the new Handlers too |
| 367 | copy(newHandlers[nowLen:], h2) |
| 368 | return newHandlers |
| 369 | } |
| 370 | |
| 371 | // UpsertHandlers like `JoinHandlers` but it does |
| 372 | // NOT copies the handlers entries and it does remove duplicates. |
no outgoing calls
no test coverage detected
searching dependent graphs…