  We present a new technique to calculate the spectral lags of gamma-ray bursts
(GRBs). Unlike previous processing methods, we first smooth the light curves of
gamma-ray bursts in high and low energy bands using the "Loess" filter, then,
we directly define the spectral lags as such to maximize the cross-correlation
function (CCF) between two smoothed light curves. This method is suitable for
various shapes of CCF; it effectively avoids the errors caused by manual
selections for the fitting function and fitting interval. Using the method, we
have carefully measured the spectral lags of individual pulses contained in
BAT/Swift gamma-ray bursts with known redshifts, and confirmed the
anti-correlation between the spectral lag and the isotropy luminosity. The
distribution of spectral lags can be well fitted by four Gaussian components,
with the centroids at 0.03 s, 0.09 s, 0.15 s, and 0.21 s, respectively. We find
that some spectral lags of the multi-peak GRBs seem to evolve with time.
