Skip to content

Commit e77e5fb

Browse files
authored
Merge pull request #49 from kornilova-l/change-push_back-to-emplace_back
Change push_back to emplace_back
2 parents 3bd4da9 + 0cd7c0f commit e77e5fb

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

bindgen/ir/IR.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,28 @@ IR::IR(std::string libName) : libName(std::move(libName)) {
1313

1414
void IR::addFunction(std::string name, std::vector<Parameter> parameters,
1515
std::string retType, bool isVariadic) {
16-
functions.push_back(Function(std::move(name), std::move(parameters),
17-
std::move(retType), isVariadic));
16+
functions.emplace_back(std::move(name), std::move(parameters),
17+
std::move(retType), isVariadic);
1818
}
1919

2020
void IR::addTypeDef(std::string name, std::string type) {
21-
typeDefs.push_back(TypeDef(std::move(name), std::move(type)));
21+
typeDefs.emplace_back(std::move(name), std::move(type));
2222
}
2323

2424
void IR::addEnum(std::string name, std::string type,
2525
std::vector<Enumerator> enumerators) {
26-
enums.push_back(
27-
Enum(std::move(name), std::move(type), std::move(enumerators)));
26+
enums.emplace_back(std::move(name), std::move(type),
27+
std::move(enumerators));
2828
}
2929

3030
void IR::addStruct(std::string name, std::vector<Field> fields,
3131
uint64_t typeSize) {
32-
structs.push_back(Struct(std::move(name), std::move(fields), typeSize));
32+
structs.emplace_back(std::move(name), std::move(fields), typeSize);
3333
}
3434

3535
void IR::addUnion(std::string name, std::vector<Field> fields,
3636
uint64_t maxSize) {
37-
unions.push_back(Union(std::move(name), std::move(fields), maxSize));
37+
unions.emplace_back(std::move(name), std::move(fields), maxSize);
3838
}
3939

4040
bool IR::libObjEmpty() const {

bindgen/visitor/TreeVisitor.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ bool TreeVisitor::VisitFunctionDecl(clang::FunctionDecl *func) {
2323

2424
std::string ptype =
2525
handleReservedWords(typeTranslator.Translate(parm->getType()));
26-
parameters.push_back(Parameter(pname, ptype));
26+
parameters.emplace_back(pname, ptype);
2727
}
2828

2929
ir->addFunction(funcName, parameters, retType, func->isVariadic());
@@ -113,7 +113,7 @@ void TreeVisitor::handleUnion(clang::RecordDecl *record, std::string name) {
113113
std::string ftype = handleReservedWords(
114114
typeTranslator.Translate(field->getType(), &name));
115115

116-
fields.push_back(Field(fname, ftype));
116+
fields.emplace_back(fname, ftype);
117117
}
118118

119119
ir->addUnion(name, fields, maxSize);
@@ -138,7 +138,7 @@ void TreeVisitor::handleStruct(clang::RecordDecl *record, std::string name) {
138138
for (const clang::FieldDecl *field : record->fields()) {
139139
std::string ftype = handleReservedWords(
140140
typeTranslator.Translate(field->getType(), &name));
141-
fields.push_back(Field(field->getNameAsString(), ftype));
141+
fields.emplace_back(field->getNameAsString(), ftype);
142142

143143
cycleDetection.AddDependcy(newName, field->getType());
144144

0 commit comments

Comments
 (0)