Skip to content

Commit

Permalink
Apply fix on update call path as well
Browse files Browse the repository at this point in the history
Signed-off-by: Julien Jerphanion <git@jjerphan.xyz>
  • Loading branch information
jjerphan committed Oct 15, 2024
1 parent d81238c commit 2d50bf4
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion libmamba/src/api/update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,19 @@ namespace mamba
{
if (auto ms = specs::MatchSpec::parse(s); ms && ms->channel().has_value())
{
ctx.channels.push_back(ms->channel()->str());
// Only register channels in the context once
// NOTE: ctx.channels could be a `std::unordered_set` but `yaml-cpp` does not
// support it. See: https://github.com/jbeder/yaml-cpp/issues/1322 Hence we
// perform linear scanning: `ctx.channels` is a short `std::vector` in practice
// so linearly searching is reasonable (probably even faster than using an
// `std::unordered_set`).
auto channel_name = ms->channel()->str();
auto channel_is_absent = std::find(ctx.channels.begin(), ctx.channels.end(), channel_name)
== ctx.channels.end();
if (channel_is_absent)
{
ctx.channels.push_back(channel_name);
}
}
}

Expand Down

0 comments on commit 2d50bf4

Please sign in to comment.