mirror of
https://github.com/gotify/server.git
synced 2026-05-07 22:06:38 +08:00
Improve the performance of the unique function by: 1. Pre-allocating map capacity with len(s) to avoid frequent map resizing 2. Pre-allocating result slice capacity with len(s) to reduce append overhead 3. Reducing the number of traversals performs well under the condition of a large number of elements These changes maintain the original behavior (preserving element order) while reducing memory allocation operations, especially effective for large slices (100k+ elements) with benchmark showing ~25% speedup. No breaking changes, the function signature and output order remain unchanged.