Avoid unnecessary dynamic cast in symbol equality function
This commit is contained in:
parent
2b883a72a2
commit
020614824a
2 changed files with 7 additions and 2 deletions
|
|
@ -17,9 +17,13 @@ namespace tree_sitter {
|
|||
index(index),
|
||||
options(options) {}
|
||||
|
||||
bool ISymbol::operator==(const ISymbol &other) const {
|
||||
return (other.index == index) && (other.options == options);
|
||||
}
|
||||
|
||||
bool ISymbol::operator==(const Rule &rule) const {
|
||||
const ISymbol *other = dynamic_cast<const ISymbol *>(&rule);
|
||||
return other && (other->index == index) && (other->options == options);
|
||||
return other && this->operator==(*other);
|
||||
}
|
||||
|
||||
size_t ISymbol::hash_code() const {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,8 @@ namespace tree_sitter {
|
|||
explicit ISymbol(int index);
|
||||
ISymbol(int index, SymbolOption options);
|
||||
|
||||
bool operator==(const Rule& other) const;
|
||||
bool operator==(const ISymbol &other) const;
|
||||
bool operator==(const Rule &other) const;
|
||||
|
||||
size_t hash_code() const;
|
||||
rule_ptr copy() const;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue