From 27aa9d2b7ed1f866820354de98297bdab0686b05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Mockers?= Date: Wed, 26 Jun 2024 14:49:07 +0200 Subject: [PATCH] example showcase: keep the order of the shaders imported (#14035) # Objective - After #13908, shaders imported are collected - this is done with a hashset, so order is random between executions ## Solution - Don't use a hashset, and keep the order they were found in the example --- tools/example-showcase/src/main.rs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/tools/example-showcase/src/main.rs b/tools/example-showcase/src/main.rs index 66b2811ffe..6eb4dd2a57 100644 --- a/tools/example-showcase/src/main.rs +++ b/tools/example-showcase/src/main.rs @@ -1,7 +1,7 @@ //! Tool to run all examples or generate a showcase page for the Bevy website. use std::{ - collections::{hash_map::DefaultHasher, HashMap, HashSet}, + collections::{hash_map::DefaultHasher, HashMap}, fmt::Display, fs::{self, File}, hash::{Hash, Hasher}, @@ -731,13 +731,17 @@ fn parse_examples() -> Vec { Regex::new(r"(shaders\/\w+\.wgsl)|(shaders\/\w+\.frag)|(shaders\/\w+\.vert)") .unwrap(); - // Find all instances of references to shader files, collect into set to avoid duplicates, then convert to vec of strings. - let shader_paths = Vec::from_iter( - shader_regex - .find_iter(&source_code) - .map(|matches| matches.as_str().to_owned()) - .collect::>(), - ); + // Find all instances of references to shader files, and keep them in an ordered and deduped vec. + let mut shader_paths = vec![]; + for path in shader_regex + .find_iter(&source_code) + .map(|matches| matches.as_str().to_owned()) + { + if !shader_paths.contains(&path) { + shader_paths.push(path); + } + } + if metadatas .get(&technical_name) .and_then(|metadata| metadata.get("hidden"))