Skip to content

Commit

Permalink
reduce smart_pointer copies in ast
Browse files Browse the repository at this point in the history
copy of smart pointer isn't too expensive, but it costs more than usage of const ref. And when we call some of function many time it can give visible speed up a few percent for huge amount of code
  • Loading branch information
Einzich committed Feb 9, 2024
1 parent 7cd52a9 commit ebe36c3
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion include/daScript/ast/ast_handle.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ namespace das
virtual void aotVisitGetField(TextWriter & ss, const string & fieldName) override;
virtual void aotVisitGetFieldPtr(TextWriter & ss, const string & fieldName) override;
virtual bool canSubstitute(TypeAnnotation * ann) const override;
StructureField & addFieldEx(const string & na, const string & cppNa, off_t offset, TypeDeclPtr pT);
StructureField & addFieldEx(const string & na, const string & cppNa, off_t offset, const TypeDeclPtr & pT);
virtual void walk(DataWalker & walker, void * data) override;
void updateTypeInfo() const;
int32_t fieldCount() const { return int32_t(fields.size()); }
Expand Down
2 changes: 1 addition & 1 deletion include/daScript/ast/ast_typedecl.h
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ namespace das {

bool isCircularType ( const TypeDeclPtr & type );
bool hasImplicit ( const TypeDeclPtr & type );
bool isMatchingArgumentType (TypeDeclPtr argType, TypeDeclPtr passType);
bool isMatchingArgumentType ( const TypeDeclPtr & argType, const TypeDeclPtr & passType );

enum class CpptSubstitureRef { no, yes };
enum class CpptSkipRef { no, yes };
Expand Down
2 changes: 1 addition & 1 deletion src/ast/ast_handle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ namespace das {
}
}

BasicStructureAnnotation::StructureField & BasicStructureAnnotation::addFieldEx ( const string & na, const string & cppNa, off_t offset, TypeDeclPtr pT ) {
BasicStructureAnnotation::StructureField & BasicStructureAnnotation::addFieldEx ( const string & na, const string & cppNa, off_t offset, const TypeDeclPtr & pT ) {
auto & field = fields[na];
if ( field.decl ) {
DAS_FATAL_ERROR("structure field %s already exist in structure %s\n", na.c_str(), name.c_str() );
Expand Down
2 changes: 1 addition & 1 deletion src/ast/ast_typedecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3136,7 +3136,7 @@ namespace das
return false;
}

bool isMatchingArgumentType (TypeDeclPtr argType, TypeDeclPtr passType) {
bool isMatchingArgumentType ( const TypeDeclPtr & argType, const TypeDeclPtr & passType ) {
if (!passType) {
return false;
}
Expand Down

0 comments on commit ebe36c3

Please sign in to comment.