MCPcopy Create free account
hub / github.com/ChrisFeldmeier/OpenCodeRust / deduplicate_plugins

Function deduplicate_plugins

crates/opencode-config/src/loader.rs:1234–1247  ·  view source on GitHub ↗

Deduplicate plugins by name, with later entries (higher priority) winning. Since plugins are added in low-to-high priority order, we reverse, deduplicate (keeping first occurrence), then restore order.

(plugins: Vec<String>)

Source from the content-addressed store, hash-verified

1232/// Since plugins are added in low-to-high priority order,
1233/// we reverse, deduplicate (keeping first occurrence), then restore order.
1234pub fn deduplicate_plugins(plugins: Vec<String>) -> Vec<String> {
1235 let mut seen = std::collections::HashSet::new();
1236 let mut unique: Vec<String> = Vec::new();
1237
1238 for specifier in plugins.iter().rev() {
1239 let name = get_plugin_name(specifier);
1240 if seen.insert(name) {
1241 unique.push(specifier.clone());
1242 }
1243 }
1244
1245 unique.reverse();
1246 unique
1247}
1248
1249/// Apply post-load transforms: legacy migrations, flag overrides, plugin dedup.
1250fn apply_post_load_transforms(config: &mut Config) {

Callers 1

Calls 3

newFunction · 0.85
get_plugin_nameFunction · 0.85
cloneMethod · 0.45

Tested by

no test coverage detected