mirror of
https://github.com/zeek/zeek.git
synced 2025-10-06 08:38:20 +00:00
TableType: Simplify and inline Is...Index tests
This commit is contained in:
parent
96a0312ad2
commit
e68194f2df
2 changed files with 8 additions and 16 deletions
14
src/Type.cc
14
src/Type.cc
|
@ -382,20 +382,6 @@ void IndexType::DescribeReST(ODesc* d, bool roles_only) const {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IndexType::IsSubNetIndex() const {
|
|
||||||
const auto& types = indices->GetTypes();
|
|
||||||
if ( types.size() == 1 && types[0]->Tag() == TYPE_SUBNET )
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IndexType::IsPatternIndex() const {
|
|
||||||
const auto& types = indices->GetTypes();
|
|
||||||
if ( types.size() == 1 && types[0]->Tag() == TYPE_PATTERN )
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
detail::TraversalCode IndexType::Traverse(detail::TraversalCallback* cb) const {
|
detail::TraversalCode IndexType::Traverse(detail::TraversalCallback* cb) const {
|
||||||
auto tc = cb->PreType(this);
|
auto tc = cb->PreType(this);
|
||||||
HANDLE_TC_TYPE_PRE(tc);
|
HANDLE_TC_TYPE_PRE(tc);
|
||||||
|
|
10
src/Type.h
10
src/Type.h
|
@ -354,10 +354,16 @@ public:
|
||||||
void DescribeReST(ODesc* d, bool roles_only = false) const override;
|
void DescribeReST(ODesc* d, bool roles_only = false) const override;
|
||||||
|
|
||||||
// Returns true if this table is solely indexed by subnet.
|
// Returns true if this table is solely indexed by subnet.
|
||||||
bool IsSubNetIndex() const;
|
bool IsSubNetIndex() const {
|
||||||
|
const auto& types = indices->GetTypes();
|
||||||
|
return types.size() == 1 && types[0]->Tag() == TYPE_SUBNET;
|
||||||
|
}
|
||||||
|
|
||||||
// Returns true if this table has a single index of type pattern.
|
// Returns true if this table has a single index of type pattern.
|
||||||
bool IsPatternIndex() const;
|
bool IsPatternIndex() const {
|
||||||
|
const auto& types = indices->GetTypes();
|
||||||
|
return types.size() == 1 && types[0]->Tag() == TYPE_PATTERN;
|
||||||
|
}
|
||||||
|
|
||||||
detail::TraversalCode Traverse(detail::TraversalCallback* cb) const override;
|
detail::TraversalCode Traverse(detail::TraversalCallback* cb) const override;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue