Describe an instance where you optimized a legacy code path for better performance.
For the coding portion, implement the optimized equivalent: given a list of values, return a new list containing each value once, preserving its first-occurrence order. Use deduplicate(values); inputs and outputs are lists of integers. For example, [4, 2, 4, 1, 2] returns [4, 2, 1], and [] returns []. The input length is at most 10^4.
def deduplicate(values):