Tile grid overlay: gate rayon to native so the web build compiles (#4694)

#4217 used rayon's par_iter in ui-egui unconditionally, but rayon is a
native-only dependency there, so cargo xtask wasm failed on main.

Co-authored-by: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Brandon ThomasandClaude Opus 5.5 authored and GitHub committed 2026-10-12 23:20:45 -04:00
1 parent 70e182b08f
commit 72b499a28f
1 file changed
+8
+8
View File
@@ -21,6 +21,7 @@ use std::sync::Arc;
use egui::{Align2, Color32, FontId, Painter, Shape, Stroke};
use photocraft_geom::{Rect as DRect, TILE_SIZE, TileCoord};
use photocraft_raster::{Surface, Tile};
#[cfg(not(target_arch = "wasm32"))]
use rayon::prelude::*;
use crate::PhotocraftApp;
@@ -70,11 +71,18 @@ pub fn tile_infos(s: &Surface, parallel: bool) -> Vec<TileInfo> {
by_ptr.entry(ptr(t)).or_insert(t);
}
let distinct: Vec<(usize, &Arc<Tile>)> = by_ptr.into_iter().collect();
// rayon is a native-only dependency; the web build hashes serially.
#[cfg(not(target_arch = "wasm32"))]
let hashed: Vec<(usize, u64)> = if parallel {
distinct.par_iter().map(|(p, t)| (*p, content_hash(t))).collect()
} else {
distinct.iter().map(|(p, t)| (*p, content_hash(t))).collect()
};
#[cfg(target_arch = "wasm32")]
let hashed: Vec<(usize, u64)> = {
let _ = parallel;
distinct.iter().map(|(p, t)| (*p, content_hash(t))).collect()
};
let hash_of: HashMap<usize, u64> = hashed.into_iter().collect();
let mut count: HashMap<u64, usize> = HashMap::new();
for (_, t) in s.tiles() {