Skip to content

Commit 47f215e

Browse files
JessyTsuiclaude
andcommitted
Fix random example: mix nanos with PID for better distribution
The previous seed (raw nanos % 20) produced the same index on consecutive runs. XOR-shift nanos and add PID for variety. Bump to 0.0.20. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent ce4bf9d commit 47f215e

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cerul"
3-
version = "0.0.19"
3+
version = "0.0.20"
44
edition = "2021"
55
description = "Official Cerul CLI - search video knowledge from your terminal"
66
license = "MIT"

src/main.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,13 @@ const EXAMPLE_QUERIES: &[&str] = &[
191191

192192
fn pick_example_query() -> &'static str {
193193
use std::time::{SystemTime, UNIX_EPOCH};
194-
let seed = SystemTime::now()
194+
let nanos = SystemTime::now()
195195
.duration_since(UNIX_EPOCH)
196196
.unwrap_or_default()
197-
.as_nanos() as usize;
197+
.as_nanos();
198+
// Mix bits for better distribution: XOR high and low, add PID
199+
let pid = std::process::id() as u128;
200+
let seed = ((nanos ^ (nanos >> 17)).wrapping_add(pid)) as usize;
198201
EXAMPLE_QUERIES[seed % EXAMPLE_QUERIES.len()]
199202
}
200203

0 commit comments

Comments
 (0)