Repository: servo/servo
File: components/compositing/largest_contentful_paint_calculator.rs (Rust)

Code before:
impl LargestContentfulPaintCalculator {
    pub(crate) fn new() -> Self {
        Self {
            lcp_containers: Default::default(),
            disabled_lcp_for_webviews: Default::default(),
        }
    }

    pub fn append_lcp_candidate(
        &mut self,
        webview_id: WebViewId,
        pipeline_id: PipelineId,
        candidate: LCPCandidate,
    ) -> bool {
        if self.disabled_lcp_for_webviews.contains(&webview_id) {
            return false;
        }
        self.lcp_containers
            .entry(pipeline_id)
            .or_default()
            .lcp_candidates
            .push(candidate);
        true
    }

    pub fn remove_lcp_candidates_for_pipeline(&mut self, pipeline_id: PipelineId) {
        self.lcp_containers.remove(&pipeline_id);
    }

    pub fn calculate_largest_contentful_paint(
        &mut self,
        paint_time: CrossProcessInstant,
        pipeline_id: PipelineId,
    ) -> Option<LargestContentfulPaint> {
        self.lcp_containers
            .get_mut(&pipeline_id)
            .and_then(|container| container.calculate_largest_contentful_paint(paint_time))
    }

    pub fn add_to_disabled_lcp_webviews(&mut self, webview_id: WebViewId) {
        self.disabled_lcp_for_webviews.insert(webview_id);
    }

    pub fn clear(&mut self) {
        self.lcp_containers.clear();
        self.disabled_lcp_for_webviews.clear();
    }
}

/// Holds the LCP candidates and the latest LCP for a specific pipeline.
#[derive(Default)]

Review comment (suggestion):
```suggestion
    pub fn(crate) remove_lcp_candidates_for_pipeline(&mut self, pipeline_id: PipelineId) {
```

Code after:
impl LargestContentfulPaintCalculator {
    pub(crate) fn new() -> Self {
        Self {
            lcp_containers: Default::default(),
            disabled_lcp_for_webviews: Default::default(),
        }
    }

    pub(crate) fn append_lcp_candidate(
        &mut self,
        webview_id: WebViewId,
        pipeline_id: PipelineId,
        candidate: LCPCandidate,
    ) -> bool {
        if self.disabled_lcp_for_webviews.contains(&webview_id) {
            return false;
        }
        self.lcp_containers
            .entry(pipeline_id)
            .or_default()
            .lcp_candidates
            .push(candidate);
        true
    }

    pub(crate) fn remove_lcp_candidates_for_pipeline(&mut self, pipeline_id: PipelineId) {
        self.lcp_containers.remove(&pipeline_id);
    }

    pub(crate) fn calculate_largest_contentful_paint(
        &mut self,
        paint_time: CrossProcessInstant,
        pipeline_id: PipelineId,
    ) -> Option<LargestContentfulPaint> {
        self.lcp_containers
            .get_mut(&pipeline_id)
            .and_then(|container| container.calculate_largest_contentful_paint(paint_time))
    }

    pub(crate) fn add_to_disabled_lcp_webviews(&mut self, webview_id: WebViewId) {
        self.disabled_lcp_for_webviews.insert(webview_id);
    }

    pub(crate) fn clear(&mut self) {
        self.lcp_containers.clear();
        self.disabled_lcp_for_webviews.clear();
    }
}

/// Holds the LCP candidates and the latest LCP for a specific pipeline.
#[derive(Default)]