Repository: alacritty/alacritty
File: alacritty/src/config/monitor.rs (Rust)

Code before:
            .iter()
            .map(|path| {
                let mut path = path.clone();
                path.pop();
                path
            })
            .collect::<Vec<PathBuf>>();
        parents.sort_unstable();
        parents.dedup();

        // Watch all configuration file directories.
        for parent in &parents {
            if let Err(err) = watcher.watch(parent, RecursiveMode::NonRecursive) {
                debug!("Unable to watch config directory {:?}: {}", parent, err);
            }
        }

        // The current debouncing time.
        let mut debouncing_deadline: Option<Instant> = None;

        // The events accumulated during the debounce period.
        let mut received_events = Vec::new();

        loop {
            // We use `recv_timeout` to debounce the events comming from the watcher and reduce
            // the amount of config reloads.
            let event = if let Some(debouncing_deadline) = debouncing_deadline {
                rx.recv_timeout(debouncing_deadline.saturating_duration_since(Instant::now()))
            } else {
                let event = rx.recv().map_err(Into::into);
                // Set the debouncing deadline after receiving the event.
                debouncing_deadline = Some(Instant::now() + DEBOUNCE_DELAY);
                event
            };

            match event {
                Ok(Ok(event)) => match event.kind {
                    EventKind::Any
                    | EventKind::Create(_)
                    | EventKind::Modify(_)
                    | EventKind::Other => {
                        received_events.push(event);
                    },
                    _ => (),
                },
                Err(RecvTimeoutError::Timeout) => {
                    // Go back to polling the events.
                    debouncing_deadline = None;

                    if received_events
                        .drain(..)

Review comment (suggestion):
```suggestion
            // We use `recv_timeout` to debounce the events coming from the watcher and reduce
            // the amount of config reloads.
```

Code after:
            .iter()
            .map(|path| {
                let mut path = path.clone();
                path.pop();
                path
            })
            .collect::<Vec<PathBuf>>();
        parents.sort_unstable();
        parents.dedup();

        // Watch all configuration file directories.
        for parent in &parents {
            if let Err(err) = watcher.watch(parent, RecursiveMode::NonRecursive) {
                debug!("Unable to watch config directory {:?}: {}", parent, err);
            }
        }

        // The current debouncing time.
        let mut debouncing_deadline: Option<Instant> = None;

        // The events accumulated during the debounce period.
        let mut received_events = Vec::new();

        loop {
            // We use `recv_timeout` to debounce the events coming from the watcher and reduce
            // the amount of config reloads.
            let event = match debouncing_deadline.as_ref() {
                Some(debouncing_deadline) => {
                    rx.recv_timeout(debouncing_deadline.saturating_duration_since(Instant::now()))
                },
                None => {
                    let event = rx.recv().map_err(Into::into);
                    // Set the debouncing deadline after receiving the event.
                    debouncing_deadline = Some(Instant::now() + DEBOUNCE_DELAY);
                    event
                },
            };

            match event {
                Ok(Ok(event)) => match event.kind {
                    EventKind::Any
                    | EventKind::Create(_)
                    | EventKind::Modify(_)
                    | EventKind::Other => {
                        received_events.push(event);
                    },
                    _ => (),
                },
                Err(RecvTimeoutError::Timeout) => {
                    // Go back to polling the events.
                    debouncing_deadline = None;