Skip to content

Commit

Permalink
Remove a few value copies.
Browse files Browse the repository at this point in the history
  • Loading branch information
bbannier committed Jul 31, 2024
1 parent 4d577e9 commit c3abbbe
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
3 changes: 1 addition & 2 deletions hilti/toolchain/include/ast/ast-context.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,7 @@ class ASTContext : public std::enable_shared_from_this<ASTContext> {
std::vector<hilti::rt::filesystem::path> search_dirs);

/** Adds a new, empty module to the AST. */
declaration::Module* newModule(Builder* builder, const ID& id,
const hilti::rt::filesystem::path& process_extension);
declaration::Module* newModule(Builder* builder, ID id, const hilti::rt::filesystem::path& process_extension);

/**
* Retrieves a module node from the AST given its UID. Returns null if no
Expand Down
9 changes: 4 additions & 5 deletions hilti/toolchain/include/ast/declarations/module-uid.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,11 @@ struct UID {
* @param parse_extension language extension determining how to *parse* this module
* @param process_extension language extension determining how to process this module *after* parsing
**/
UID(const ID& id, const hilti::rt::filesystem::path& parse_extension,
const hilti::rt::filesystem::path& process_extension)
: id(id),
UID(ID id, hilti::rt::filesystem::path parse_extension, hilti::rt::filesystem::path process_extension)
: id(std::move(id)),
unique(_makeUnique(this->id)),
parse_extension(parse_extension),
process_extension(process_extension),
parse_extension(std::move(parse_extension)),
process_extension(std::move(process_extension)),
in_memory(true) {
assert(this->id && ! parse_extension.empty() && ! process_extension.empty());
// just make up a path
Expand Down
4 changes: 2 additions & 2 deletions hilti/toolchain/src/ast/ast-context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ Result<declaration::module::UID> ASTContext::importModule(
return uid;
}

declaration::Module* ASTContext::newModule(Builder* builder, const ID& id,
declaration::Module* ASTContext::newModule(Builder* builder, ID id,
const hilti::rt::filesystem::path& process_extension) {
auto uid = declaration::module::UID(id, process_extension, process_extension);
auto uid = declaration::module::UID(std::move(id), process_extension, process_extension);
auto m = builder->declarationModule(uid);
_addModuleToAST(m);
return module(uid);
Expand Down

0 comments on commit c3abbbe

Please sign in to comment.