Fix peak find slow speed when spectrum has a large number of data points

min(xdata) is a slow way to write xdata[0]

max(xdata) is a slow way to write xdata[-1]