From 6bd2f8758ee0d81aa6f31e0590f1f2270847ba9c Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Sun, 10 Aug 2025 22:32:25 +0300 Subject: [PATCH] Simplify the lock usage (#35957) Follow-up of https://github.com/zed-industries/zed/pull/35955 Release Notes: - N/A Co-authored-by: Piotr Osiewicz --- crates/onboarding/src/theme_preview.rs | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/crates/onboarding/src/theme_preview.rs b/crates/onboarding/src/theme_preview.rs index 9d86137b0b844cad3f5ed8d64883405f8c4c8d86..9f299eb6ea0a994097bac282b60f08decb7ed838 100644 --- a/crates/onboarding/src/theme_preview.rs +++ b/crates/onboarding/src/theme_preview.rs @@ -2,7 +2,7 @@ use gpui::{Hsla, Length}; use std::{ cell::LazyCell, - sync::{Arc, OnceLock}, + sync::{Arc, LazyLock, OnceLock}, }; use theme::{Theme, ThemeColors, ThemeRegistry}; use ui::{ @@ -25,17 +25,14 @@ pub struct ThemePreviewTile { style: ThemePreviewStyle, } -fn child_radius() -> Pixels { - static CHILD_RADIUS: OnceLock = OnceLock::new(); - *CHILD_RADIUS.get_or_init(|| { - inner_corner_radius( - ThemePreviewTile::ROOT_RADIUS, - ThemePreviewTile::ROOT_BORDER, - ThemePreviewTile::ROOT_PADDING, - ThemePreviewTile::CHILD_BORDER, - ) - }) -} +static CHILD_RADIUS: LazyLock = LazyLock::new(|| { + inner_corner_radius( + ThemePreviewTile::ROOT_RADIUS, + ThemePreviewTile::ROOT_BORDER, + ThemePreviewTile::ROOT_PADDING, + ThemePreviewTile::CHILD_BORDER, + ) +}); impl ThemePreviewTile { pub const SKELETON_HEIGHT_DEFAULT: Pixels = px(2.); @@ -229,7 +226,7 @@ impl ThemePreviewTile { .child( div() .size_full() - .rounded(child_radius()) + .rounded(*CHILD_RADIUS) .border(Self::CHILD_BORDER) .border_color(theme.colors().border) .child(Self::render_editor( @@ -257,7 +254,7 @@ impl ThemePreviewTile { h_flex() .size_full() .relative() - .rounded(child_radius()) + .rounded(*CHILD_RADIUS) .border(Self::CHILD_BORDER) .border_color(border_color) .overflow_hidden()