From e585ec06f403dd5fbec2db4b83c7210a2c555172 Mon Sep 17 00:00:00 2001 From: glenlow Date: Fri, 27 Jun 2008 09:41:26 +0000 Subject: [PATCH] ensure pluginsWithAPI: returns a sorted, unique list of plugins --- macosx/GVGraph.m | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/macosx/GVGraph.m b/macosx/GVGraph.m index 5bf6753f8..5ce318166 100644 --- a/macosx/GVGraph.m +++ b/macosx/GVGraph.m @@ -37,9 +37,7 @@ static GVC_t *_graphContext = nil; + (NSArray *)pluginsWithAPI:(api_t)api { - /* need to filter out repeated plugins i.e. plugins that have the same format + render but different package */ - NSMutableSet *distinctPlugins = [NSMutableSet set]; - NSMutableArray *plugins = [NSMutableArray array]; + NSMutableSet *plugins = [NSMutableSet set]; /* go through each non-empty plugin in the list, ignoring the package part */ char *pluginList = gvplugin_list(_graphContext, api, ":"); @@ -50,17 +48,13 @@ static GVC_t *_graphContext = nil; char *lastColon = strrchr(nextPlugin, ':'); if (lastColon) { *lastColon = '\0'; - NSString *plugin = [NSString stringWithCString:nextPlugin encoding:NSUTF8StringEncoding]; - if (![distinctPlugins containsObject:plugin]) { - [plugins addObject:plugin]; - [distinctPlugins addObject:plugin]; - } + [plugins addObject:[NSString stringWithCString:nextPlugin encoding:NSUTF8StringEncoding]]; } } } free(pluginList); - return plugins; + return [[plugins allObjects] sortedArrayUsingSelector:@selector(compare:)]; } - (id)initWithURL:(NSURL *)URL error:(NSError **)outError -- 2.40.0