Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove const ref to string_view in codebase #2440

Merged
merged 1 commit into from
Apr 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions libmamba/include/mamba/core/output.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,19 +104,18 @@ namespace mamba

static Console& instance();
static ConsoleStream stream();
static bool prompt(const std::string_view& message, char fallback = '_');
static bool
prompt(const std::string_view& message, char fallback, std::istream& input_stream);
static bool prompt(std::string_view message, char fallback = '_');
static bool prompt(std::string_view message, char fallback, std::istream& input_stream);

ProgressProxy add_progress_bar(const std::string& name, size_t expected_total = 0);
void clear_progress_bars();
ProgressBarManager& init_progress_bar_manager(ProgressBarMode mode = ProgressBarMode::multi);
void terminate_progress_bar_manager();
ProgressBarManager& progress_bar_manager();

static std::string hide_secrets(const std::string_view& str);
static std::string hide_secrets(std::string_view str);

void print(const std::string_view& str, bool force_print = false);
void print(std::string_view str, bool force_print = false);
void json_write(const nlohmann::json& j);
void json_append(const std::string& value);
void json_append(const nlohmann::json& j);
Expand All @@ -135,7 +134,7 @@ namespace mamba
private:

void json_print();
void deactivate_progress_bar(std::size_t idx, const std::string_view& msg = "");
void deactivate_progress_bar(std::size_t idx, std::string_view msg = "");

std::unique_ptr<ConsoleData> p_data;

Expand Down
6 changes: 3 additions & 3 deletions libmamba/include/mamba/core/util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ namespace mamba
}
};

bool is_package_file(const std::string_view& fn);
bool is_package_file(std::string_view fn);

bool lexists(const fs::u8path& p);
bool lexists(const fs::u8path& p, std::error_code& ec);
Expand Down Expand Up @@ -265,8 +265,8 @@ namespace mamba
&& prefix.end() == std::mismatch(prefix.begin(), prefix.end(), vec.begin()).first;
}

tl::expected<std::string, mamba_error> encode_base64(const std::string_view& input);
tl::expected<std::string, mamba_error> decode_base64(const std::string_view& input);
tl::expected<std::string, mamba_error> encode_base64(std::string_view input);
tl::expected<std::string, mamba_error> decode_base64(std::string_view input);


// get the value corresponding to a key in a JSON object and assign it to target
Expand Down
2 changes: 1 addition & 1 deletion libmamba/src/core/link.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace mamba
out << " sys.exit(" << p.func << "())\n";
}

void application_entry_point_template(std::ostream& out, const std::string_view& source_full_path)
void application_entry_point_template(std::ostream& out, std::string_view source_full_path)
{
out << "# -*- coding: utf-8 -*-\n";
out << "if __name__ == '__main__':\n";
Expand Down
8 changes: 4 additions & 4 deletions libmamba/src/core/output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,12 +317,12 @@ namespace mamba
p_data->is_json_print_cancelled = true;
}

std::string Console::hide_secrets(const std::string_view& str)
std::string Console::hide_secrets(std::string_view str)
{
return mamba::hide_secrets(str);
}

void Console::print(const std::string_view& str, bool force_print)
void Console::print(std::string_view str, bool force_print)
{
if (force_print || !(Context::instance().quiet || Context::instance().json))
{
Expand Down Expand Up @@ -353,12 +353,12 @@ namespace mamba

// We use an overload instead of a default argument to avoid exposing std::cin
// in the header (this would require to include iostream)
bool Console::prompt(const std::string_view& message, char fallback)
bool Console::prompt(std::string_view message, char fallback)
{
return Console::prompt(message, fallback, std::cin);
}

bool Console::prompt(const std::string_view& message, char fallback, std::istream& input_stream)
bool Console::prompt(std::string_view message, char fallback, std::istream& input_stream)
{
if (Context::instance().always_yes)
{
Expand Down
6 changes: 3 additions & 3 deletions libmamba/src/core/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ extern "C"

namespace mamba
{
bool is_package_file(const std::string_view& fn)
bool is_package_file(std::string_view fn)
{
return ends_with(fn, ".tar.bz2") || ends_with(fn, ".conda");
}
Expand Down Expand Up @@ -1478,7 +1478,7 @@ namespace mamba
return ends_with(filename, ".yml") || ends_with(filename, ".yaml");
}

tl::expected<std::string, mamba_error> encode_base64(const std::string_view& input)
tl::expected<std::string, mamba_error> encode_base64(std::string_view input)
{
const auto pl = 4 * ((input.size() + 2) / 3);
std::vector<unsigned char> output(pl + 1);
Expand All @@ -1496,7 +1496,7 @@ namespace mamba
return std::string(reinterpret_cast<const char*>(output.data()));
}

tl::expected<std::string, mamba_error> decode_base64(const std::string_view& input)
tl::expected<std::string, mamba_error> decode_base64(std::string_view input)
{
const auto pl = 3 * input.size() / 4;

Expand Down
6 changes: 3 additions & 3 deletions micromamba/src/microserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ namespace microserver
std::string date;
std::stringstream body;

void send(const std::string_view& str)
void send(std::string_view str)
{
body << str;
}
Expand Down Expand Up @@ -118,14 +118,14 @@ namespace microserver
private:

void main_loop(int port);
std::pair<std::string, std::string> parse_header(const std::string_view&);
std::pair<std::string, std::string> parse_header(std::string_view);
void parse_headers(const std::string&, Request&, Response&);
bool match_route(Request&, Response&);
std::vector<Route> m_routes;
spdlog::logger m_logger;
};

std::pair<std::string, std::string> Server::parse_header(const std::string_view& header)
std::pair<std::string, std::string> Server::parse_header(std::string_view header)
{
assert(header.size() >= 2);
assert(header[header.size() - 1] == '\n' && header[header.size() - 2] == '\r');
Expand Down