Closed toxicwind closed 11 months ago
This should be deterministic and prevent duplicates, unlike the last one.
Wouldn't caching prevent users from getting updates to their wildcards? A lot of people, myself included edit those files often. For example if I setup a custom scene wildcard to use for a specific task I often tweak weighting or add some additional stuff.
That is indeed a good point. I'm going to keep this as a patch for myself as I don't generally do that, but totally get it.
This commit significantly improves the
replace_wildcards
function with a focus on performance and duplicate prevention. The key enhancements are as follows:Custom Seeding Mechanism: Implemented a custom seeding approach to ensure reproducible randomization, enhancing predictability.
Optimized File Handling: Optimized file reading and random line selection for better performance, especially with large files.
Configuration Flexibility: Enhanced configurability by allowing custom wildcard paths to adapt to various use cases.
Caching for Duplicate Prevention: Introduced caching to store recently selected random lines, preventing duplicates within a single execution. This reduces I/O operations and enhances efficiency.
Code Documentation: Added comments and documentation to improve code clarity and maintainability.
These changes make the
replace_wildcards
function more efficient and robust, particularly in scenarios where preventing recent duplicates is crucial.