From dce1455be7c59a5ab5e3878a9d03009f42054fef Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Wed, 19 Mar 2025 08:52:02 -0700 Subject: [PATCH] Inline to_fixed_hash fn --- src-tauri/src/window.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src-tauri/src/window.rs b/src-tauri/src/window.rs index b6f0a858..ae73aff8 100644 --- a/src-tauri/src/window.rs +++ b/src-tauri/src/window.rs @@ -55,7 +55,10 @@ pub(crate) fn create_window( // macOS doesn't support data dir so must use this fn instead #[cfg(target_os = "macos")] { - win_builder = win_builder.data_store_identifier(to_fixed_hash(&key)); + let hash = md5::compute(key.as_bytes()); + let mut id = [0u8; 16]; + id.copy_from_slice(&hash[..16]); // Take the first 16 bytes of the hash + win_builder = win_builder.data_store_identifier(id); } } @@ -158,10 +161,3 @@ pub(crate) fn create_window( win } - -fn to_fixed_hash(s: &str) -> [u8; 16] { - let hash = md5::compute(s.as_bytes()); - let mut fixed = [0u8; 16]; - fixed.copy_from_slice(&hash[..16]); // Take the first 16 bytes of the hash - fixed -}