input: Write a function to optimize the given linear search function using best practices. The function should take an array and a target value as input and return the index of the target value if found in the array, and -1 if not found. If the array is empty, the function should return -1.
  assert linear_search([1, 2, 3, 4, 5], 3) == 2
  assert linear_search([1, 2, 3, 4, 5], 6) == -1
  assert linear_search([], 4) == -1
  assert linear_search([1, 3, 5, 7, 9], 9) == 4
  assert linear_search([2, 4, 6, 8, 10], 8) == 3
output: def linear_search(arr, target):
      if not arr:
          return -1
      for i, value in enumerate(arr):
          if value == target:
              return i
      return -1