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

Improve performance by skipping char copies #1398

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion src/arch-riscv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1025,7 +1025,7 @@ struct Extn {
// This function returns true if the first extension name should precede
// the second one as per the rule.
static bool extn_name_less(std::string_view x, std::string_view y) {
auto get_single_letter_rank = [](char c) -> i64 {
auto get_single_letter_rank = [](const char& c) -> i64 {
std::string_view exts = "iemafdqlcbkjtpvnh";
size_t pos = exts.find_first_of(c);
if (pos != exts.npos)
Expand Down
2 changes: 1 addition & 1 deletion src/cmdline.cc
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ static i64 parse_number(Context<E> &ctx, std::string opt,
return ret;
}

static char from_hex(char c) {
static char from_hex(const char& c) {
if ('0' <= c && c <= '9')
return c - '0';
if ('a' <= c && c <= 'f')
Expand Down
2 changes: 1 addition & 1 deletion src/filetype.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace mold {

static bool is_text_file(MappedFile *mf) {
auto istext = [](char c) {
auto istext = [](const char& c) {
return isprint(c) || c == '\n' || c == '\t';
};

Expand Down
4 changes: 2 additions & 2 deletions src/mold.h
Original file line number Diff line number Diff line change
Expand Up @@ -3096,11 +3096,11 @@ inline bool is_c_identifier(std::string_view s) {
if (s.empty())
return false;

auto is_alpha = [](char c) {
auto is_alpha = [](const char& c) {
return c == '_' || ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z');
};

auto is_alnum = [&](char c) {
auto is_alnum = [&](const char& c) {
return is_alpha(c) || ('0' <= c && c <= '9');
};

Expand Down
2 changes: 1 addition & 1 deletion src/passes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ get_start_stop_name(Context<E> &ctx, Chunk<E> &chunk) {
return std::string(chunk.name);

if (ctx.arg.start_stop) {
auto isalnum = [](char c) {
auto isalnum = [](const char& c) {
return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') ||
('0' <= c && c <= '9');
};
Expand Down
Loading