optimize_patterns() — tailwindcss Function Reference
Architecture documentation for the optimize_patterns() function in glob.rs from the tailwindcss codebase.
Entity Profile
Dependency Diagram
graph TD f569f1f4_b5a2_4b65_df8e_64243846541d["optimize_patterns()"] 3ae15a03_28aa_2117_2ea0_09d75795dc8b["test()"] 3ae15a03_28aa_2117_2ea0_09d75795dc8b -->|calls| f569f1f4_b5a2_4b65_df8e_64243846541d 32fd280d_8a0c_065c_78a7_8bfcab67fb4f["hoist_static_glob_parts()"] f569f1f4_b5a2_4b65_df8e_64243846541d -->|calls| 32fd280d_8a0c_065c_78a7_8bfcab67fb4f style f569f1f4_b5a2_4b65_df8e_64243846541d fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
crates/oxide/src/glob.rs lines 91–133
pub fn optimize_patterns(entries: &Vec<GlobEntry>) -> Vec<GlobEntry> {
let entries = hoist_static_glob_parts(entries, true);
// Track all base paths and their patterns. Later we will turn them back into `GlobalEntry`s.
let mut pattern_map: FxHashMap<String, FxHashSet<String>> = FxHashMap::default();
for glob_entry in entries {
let entry = pattern_map.entry(glob_entry.base).or_default();
entry.insert(glob_entry.pattern.clone());
}
let mut glob_entries = pattern_map
.into_iter()
.map(|(base, patterns)| {
let size = patterns.len();
let mut patterns = patterns.into_iter();
GlobEntry {
base,
pattern: match size {
// SAFETY: we can unwrap here because we know that the size is 1.
1 => patterns.next().unwrap(),
_ => {
let mut patterns = patterns.collect::<Vec<_>>();
// Sort the patterns to ensure stable results.
patterns.sort();
// TODO: Right now this will generate something like `{**/*.html,**/*.js}`,
// but maybe we want to generate this instead:`**/*.{html,js}`.
format!("{{{}}}", patterns.join(","))
}
},
}
})
.collect::<Vec<GlobEntry>>();
// Sort the entries by base path to ensure we have stable results.
glob_entries.sort_by(|a, z| a.base.cmp(&z.base));
glob_entries
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does optimize_patterns() do?
optimize_patterns() is a function in the tailwindcss codebase.
What does optimize_patterns() call?
optimize_patterns() calls 1 function(s): hoist_static_glob_parts.
What calls optimize_patterns()?
optimize_patterns() is called by 1 function(s): test.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free