input: Write a function to optimize the given Python code to be more efficient. The original code iterates over a list `data` and appends elements greater than 2 to a list `result`. If an optimized version of the code can produce the same result, return it; otherwise, return the original code.
  assert optimize_code([1, 2, 3, 4])==[x for x in [1, 2, 3, 4] if x > 2]
  assert optimize_code([1, 2, 3, 4, 5])==[x for x in [1, 2, 3, 4, 5] if x > 2]
  assert optimize_code([1, 2])==[]
  assert optimize_code([1, 2, 3, 4])==[x for x in [1, 2, 3, 4] if x > 2]
  assert optimize_code([])==[]
output: def optimize_code(data):
      return [x for x in data if x > 2]