mirror of
https://github.com/zeek/zeek.git
synced 2025-10-09 01:58:20 +00:00
Add early bail-outs to same_type()
This commit is contained in:
parent
8816547964
commit
6f61463a48
1 changed files with 16 additions and 0 deletions
16
src/Type.h
16
src/Type.h
|
@ -828,21 +828,37 @@ extern bool same_type(const Type& t1, const Type& t2, bool is_init = false,
|
||||||
inline bool same_type(const TypePtr& t1, const TypePtr& t2, bool is_init = false,
|
inline bool same_type(const TypePtr& t1, const TypePtr& t2, bool is_init = false,
|
||||||
bool match_record_field_names = true)
|
bool match_record_field_names = true)
|
||||||
{
|
{
|
||||||
|
// If the pointers are identical, the type should be the same type.
|
||||||
|
if ( t1.get() == t2.get() )
|
||||||
|
return true;
|
||||||
|
|
||||||
return same_type(*t1, *t2, is_init, match_record_field_names);
|
return same_type(*t1, *t2, is_init, match_record_field_names);
|
||||||
}
|
}
|
||||||
inline bool same_type(const Type* t1, const Type* t2, bool is_init = false,
|
inline bool same_type(const Type* t1, const Type* t2, bool is_init = false,
|
||||||
bool match_record_field_names = true)
|
bool match_record_field_names = true)
|
||||||
{
|
{
|
||||||
|
// If the pointers are identical, the type should be the same type.
|
||||||
|
if ( t1 == t2 )
|
||||||
|
return true;
|
||||||
|
|
||||||
return same_type(*t1, *t2, is_init, match_record_field_names);
|
return same_type(*t1, *t2, is_init, match_record_field_names);
|
||||||
}
|
}
|
||||||
inline bool same_type(const TypePtr& t1, const Type* t2, bool is_init = false,
|
inline bool same_type(const TypePtr& t1, const Type* t2, bool is_init = false,
|
||||||
bool match_record_field_names = true)
|
bool match_record_field_names = true)
|
||||||
{
|
{
|
||||||
|
// If the pointers are identical, the type should be the same type.
|
||||||
|
if ( t1.get() == t2 )
|
||||||
|
return true;
|
||||||
|
|
||||||
return same_type(*t1, *t2, is_init, match_record_field_names);
|
return same_type(*t1, *t2, is_init, match_record_field_names);
|
||||||
}
|
}
|
||||||
inline bool same_type(const Type* t1, const TypePtr& t2, bool is_init = false,
|
inline bool same_type(const Type* t1, const TypePtr& t2, bool is_init = false,
|
||||||
bool match_record_field_names = true)
|
bool match_record_field_names = true)
|
||||||
{
|
{
|
||||||
|
// If the pointers are identical, the type should be the same type.
|
||||||
|
if ( t1 == t2.get() )
|
||||||
|
return true;
|
||||||
|
|
||||||
return same_type(*t1, *t2, is_init, match_record_field_names);
|
return same_type(*t1, *t2, is_init, match_record_field_names);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue