Dedupe the entries with last-entry-wins semantics.
(entries []archiveEntry)
| 340 | |
| 341 | // Dedupe the entries with last-entry-wins semantics. |
| 342 | func dedupeEntries(entries []archiveEntry) []archiveEntry { |
| 343 | seenIndex := make(map[string]int, len(entries)) |
| 344 | result := make([]archiveEntry, 0, len(entries)) |
| 345 | for i, entry := range entries { |
| 346 | seenIndex[entry.header.Name] = i |
| 347 | } |
| 348 | for i, entry := range entries { |
| 349 | if seenIndex[entry.header.Name] == i { |
| 350 | result = append(result, entry) |
| 351 | } |
| 352 | } |
| 353 | return result |
| 354 | } |