Skip to content

Commit 4cb7e30

Browse files
authored
Optimize rule loading procedure and scan expr maps sequentually via hashing (#51)
1 parent 6b67cf5 commit 4cb7e30

45 files changed

Lines changed: 1021 additions & 1108 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cpp2rust/converter/converter.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3558,7 +3558,7 @@ std::string Converter::ConvertMappedMethodCall(
35583558
std::string Converter::GetMappedAsString(clang::Expr *expr, clang::Expr **args,
35593559
unsigned num_args,
35603560
TempMaterializationCtx *ctx) {
3561-
auto *tgt_ir = Mapper::GetExprTgt(GetCalleeOrExpr(expr));
3561+
auto *tgt_ir = Mapper::GetExprRule(GetCalleeOrExpr(expr));
35623562
if (!tgt_ir)
35633563
return {};
35643564

@@ -3582,18 +3582,18 @@ std::string Converter::ConvertIRFragment(
35823582
if (auto *t = std::get_if<TextFragment>(&frag)) {
35833583
result += t->text;
35843584
} else if (auto *g = std::get_if<GenericFragment>(&frag)) {
3585-
result += Mapper::InstantiateTemplate(GetCalleeOrExpr(expr), g->name);
3585+
result += Mapper::InstantiateTemplate(GetCalleeOrExpr(expr), g->n);
35863586
} else if (auto *ph = std::get_if<PlaceholderFragment>(&frag)) {
3587-
auto arg_idx = std::stoi(ph->arg.substr(1)); // "a0" -> 0
3588-
assert(arg_idx < static_cast<int>(all_args.size()));
3587+
auto arg_idx = ph->n;
3588+
assert(arg_idx < all_args.size());
35893589
auto *arg = all_args[arg_idx];
35903590
bool is_receiver = HasReceiver(expr) && arg_idx == 0;
35913591

35923592
PlaceholderCtx ph_ctx{
35933593
.param_type = Mapper::GetParamType(GetCalleeOrExpr(expr), arg_idx),
35943594
.materialize_ctx = ctx,
35953595
.materialize_idx =
3596-
is_receiver ? -1 : (arg_idx - (HasReceiver(expr) ? 1 : 0)),
3596+
is_receiver ? -1 : ((int)arg_idx - HasReceiver(expr)),
35973597
.access = ph->access,
35983598
.is_receiver = is_receiver,
35993599
.is_cpp_ptr = arg->getType()->isPointerType(),

0 commit comments

Comments
 (0)