From 7f122b088ee81a6b3810dcbc0e6a07a59f882f73 Mon Sep 17 00:00:00 2001 From: Alex Zenla Date: Sat, 1 Nov 2025 02:20:59 -0400 Subject: [PATCH] chore(context): add documentation to the stamping algorithm --- src/actions/splash.rs | 2 ++ src/context.rs | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/src/actions/splash.rs b/src/actions/splash.rs index 1cf0691..b37eed8 100644 --- a/src/actions/splash.rs +++ b/src/actions/splash.rs @@ -12,6 +12,8 @@ use std::time::Duration; use uefi::boot::ScopedProtocol; use uefi::proto::console::gop::GraphicsOutput; +/// We set the default splash time to zero, as this makes it so any logging shows up +/// on top of the splash and does not hold up the boot process. const DEFAULT_SPLASH_TIME: u32 = 0; /// The configuration of the splash action. diff --git a/src/context.rs b/src/context.rs index cc15ab2..e194f88 100644 --- a/src/context.rs +++ b/src/context.rs @@ -219,6 +219,14 @@ impl SproutContext { /// Stamps the `text` value with the specified `values` map. The returned value indicates /// whether the `text` has been changed and the value that was stamped and changed. + /// + /// Stamping works like this: + /// - Start with the input text. + /// - Sort all the keys in reverse length order (longest keys first) + /// - For each key, if the key is not empty, replace $KEY in the text. + /// - Each follow-up iteration acts upon the last iterations result. + /// - We keep track if the text changes during the replacement. + /// - We return both whether the text changed during any iteration and the final result. fn stamp_values(values: &BTreeMap, text: impl AsRef) -> (bool, String) { let mut result = text.as_ref().to_string(); let mut did_change = false;