diff options
author | Martin Robinson <mrobinson@igalia.com> | 2025-03-13 13:00:31 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-13 12:00:31 +0000 |
commit | 294a649a6c96ea0fba05fad59a41dea6c7f1d66d (patch) | |
tree | 5b3de846c3e4954ff7e4d3af666d3c82108b09f9 /components/profile | |
parent | 959720db0a15d207e31e44ffd58d76e9e31b18c9 (diff) | |
download | servo-294a649a6c96ea0fba05fad59a41dea6c7f1d66d.tar.gz servo-294a649a6c96ea0fba05fad59a41dea6c7f1d66d.zip |
Use `strum` to iterate through enum variants and get their names (#35933)
`strum` allows us to avoid manually listing enum variant names and also
to get their names as static strings. We cannot use this for all cases
due to https://github.com/Peternator7/strum/issues/152, but we can
still use it to remove a lot of code.
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Diffstat (limited to 'components/profile')
-rw-r--r-- | components/profile/time.rs | 53 |
1 files changed, 2 insertions, 51 deletions
diff --git a/components/profile/time.rs b/components/profile/time.rs index 1e7629a48f7..ce6e6eb90b3 100644 --- a/components/profile/time.rs +++ b/components/profile/time.rs @@ -85,57 +85,8 @@ impl Formattable for ProfilerCategory { ProfilerCategory::LayoutTextShaping => "| + ", _ => "", }; - let name = match *self { - ProfilerCategory::Compositing => "Compositing", - ProfilerCategory::LayoutPerform => "Layout", - ProfilerCategory::LayoutStyleRecalc => "Style Recalc", - ProfilerCategory::LayoutTextShaping => "Text Shaping", - ProfilerCategory::LayoutRestyleDamagePropagation => "Restyle Damage Propagation", - ProfilerCategory::LayoutGeneratedContent => "Generated Content Resolution", - ProfilerCategory::LayoutFloatPlacementSpeculation => "Float Placement Speculation", - ProfilerCategory::LayoutMain => "Primary Layout Pass", - ProfilerCategory::LayoutStoreOverflow => "Store Overflow", - ProfilerCategory::LayoutParallelWarmup => "Parallel Warmup", - ProfilerCategory::LayoutDispListBuild => "Display List Construction", - ProfilerCategory::ImageSaving => "Image Saving", - ProfilerCategory::ScriptAttachLayout => "Script Attach Layout", - ProfilerCategory::ScriptConstellationMsg => "Script Constellation Msg", - ProfilerCategory::ScriptDevtoolsMsg => "Script Devtools Msg", - ProfilerCategory::ScriptDocumentEvent => "Script Document Event", - ProfilerCategory::ScriptEvaluate => "Script JS Evaluate", - ProfilerCategory::ScriptFileRead => "Script File Read", - ProfilerCategory::ScriptFontLoading => "Script Font Loading", - ProfilerCategory::ScriptHistoryEvent => "Script History Event", - ProfilerCategory::ScriptImageCacheMsg => "Script Image Cache Msg", - ProfilerCategory::ScriptInputEvent => "Script Input Event", - ProfilerCategory::ScriptNetworkEvent => "Script Network Event", - ProfilerCategory::ScriptParseHTML => "Script Parse HTML", - ProfilerCategory::ScriptParseXML => "Script Parse XML", - ProfilerCategory::ScriptPlannedNavigation => "Script Planned Navigation", - ProfilerCategory::ScriptPortMessage => "Script Port Message", - ProfilerCategory::ScriptRendering => "Script Rendering", - ProfilerCategory::ScriptResize => "Script Resize", - ProfilerCategory::ScriptEvent => "Script Event", - ProfilerCategory::ScriptUpdateReplacedElement => "Script Update Replaced Element", - ProfilerCategory::ScriptSetScrollState => "Script Set Scroll State", - ProfilerCategory::ScriptSetViewport => "Script Set Viewport", - ProfilerCategory::ScriptTimerEvent => "Script Timer Event", - ProfilerCategory::ScriptStylesheetLoad => "Script Stylesheet Load", - ProfilerCategory::ScriptWebSocketEvent => "Script Web Socket Event", - ProfilerCategory::ScriptWorkerEvent => "Script Worker Event", - ProfilerCategory::ScriptServiceWorkerEvent => "Script Service Worker Event", - ProfilerCategory::ScriptEnterFullscreen => "Script Enter Fullscreen", - ProfilerCategory::ScriptExitFullscreen => "Script Exit Fullscreen", - ProfilerCategory::ScriptWorkletEvent => "Script Worklet Event", - ProfilerCategory::ScriptPerformanceEvent => "Script Performance Event", - ProfilerCategory::ScriptWebGPUMsg => "Script WebGPU Message", - ProfilerCategory::TimeToFirstPaint => "Time To First Paint", - ProfilerCategory::TimeToFirstContentfulPaint => "Time To First Contentful Paint", - ProfilerCategory::TimeToInteractive => "Time to Interactive", - ProfilerCategory::IpcReceiver => "Blocked at IPC Receive", - ProfilerCategory::IpcBytesReceiver => "Blocked at IPC Bytes Receive", - }; - format!("{}{}", padding, name) + let name: &'static str = self.into(); + format!("{padding}{name}") } } |