Skip to content

Commit d7f5b26

Browse files
cmagliefacchinm
authored andcommitted
Use utils.AppendIfNotPresent when possible
1 parent c3af9e3 commit d7f5b26

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

create_cmake_rule.go

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -210,21 +210,21 @@ func extractCompileFlags(ctx *types.Context, receipe string, defines, libs, link
210210

211211
for _, arg := range command.Args {
212212
if strings.HasPrefix(arg, "-D") {
213-
*defines = appendIfUnique(*defines, arg)
213+
*defines = utils.AppendIfNotPresent(*defines, arg)
214214
continue
215215
}
216216
if strings.HasPrefix(arg, "-l") {
217-
*libs = appendIfUnique(*libs, arg)
217+
*libs = utils.AppendIfNotPresent(*libs, arg)
218218
continue
219219
}
220220
if strings.HasPrefix(arg, "-L") {
221-
*linkDirectories = appendIfUnique(*linkDirectories, strings.TrimPrefix(arg, "-L"))
221+
*linkDirectories = utils.AppendIfNotPresent(*linkDirectories, strings.TrimPrefix(arg, "-L"))
222222
continue
223223
}
224224
if strings.HasPrefix(arg, "-") && !strings.HasPrefix(arg, "-I") && !strings.HasPrefix(arg, "-o") {
225225
// HACK : from linkerflags remove MMD (no cache is produced)
226226
if !strings.HasPrefix(arg, "-MMD") {
227-
*linkerflags = appendIfUnique(*linkerflags, arg)
227+
*linkerflags = utils.AppendIfNotPresent(*linkerflags, arg)
228228
}
229229
}
230230
}
@@ -241,10 +241,3 @@ func findUniqueFoldersRelative(slice []string, base string) string {
241241
}
242242
return strings.Join(out, " ")
243243
}
244-
245-
func appendIfUnique(slice []string, element string) []string {
246-
if !utils.SliceContains(slice, element) {
247-
slice = append(slice, element)
248-
}
249-
return slice
250-
}

0 commit comments

Comments
 (0)