Skip to content

Commit

Permalink
Make assembler 15% faster
Browse files Browse the repository at this point in the history
  • Loading branch information
Slackadays committed Dec 26, 2024
1 parent ce64529 commit 727838c
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions libchata/src/assembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,14 +491,17 @@ void parse_this_line(chatastring& this_line, assembly_context& c) {
c.arg3.clear();
c.arg4.clear();
c.arg5.clear();
auto is_whitespace = [](const char& c) {
return c == '\t' || c == ' ';
};
for (size_t i = 0; i < this_line.size(); i++) {
auto ch = [&]() {
return this_line.at(i);
};
for (; i < this_line.size() && std::isblank(ch()); i++) {
for (; i < this_line.size() && is_whitespace(ch()); i++) {
c.column++;
}
for (; i < this_line.size() && !std::isblank(ch()); i++) {
for (; i < this_line.size() && !is_whitespace(ch()); i++) {
c.inst.push_back(ch());
c.column++;
}
Expand All @@ -514,10 +517,10 @@ void parse_this_line(chatastring& this_line, assembly_context& c) {
break;
}
auto parse_arg = [&](chatastring& arg) {
for (; i < this_line.size() && (std::isblank(ch()) || ch() == ','); i++) {
for (; i < this_line.size() && (is_whitespace(ch()) || ch() == ','); i++) {
c.column++;
}
for (; i < this_line.size() && (!std::isblank(ch()) && ch() != ','); i++) {
for (; i < this_line.size() && !(is_whitespace(ch()) || ch() == ','); i++) {
arg.push_back(ch());
c.column++;
}
Expand Down

0 comments on commit 727838c

Please sign in to comment.