mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 14:01:06 +01:00
Move to by-value friend comparison operator definitions. (#222)
This is often a (much) better option for this code as we have many types that are just an integer, pointer, or enum of data that would be much more efficient as a by-value parameter. It is also a cleaner design in most cases. One place can't migrate in this way: iterators that use the LLVM CRTP library for filling out iterator methods. The CRTP dispatch expects operators to be actual members, and so those are left as-is in this patch.
This commit is contained in:
@@ -44,11 +44,11 @@ class ParseNodeKind {
|
||||
// constructed using the above factory functions for each unique kind.
|
||||
ParseNodeKind() = delete;
|
||||
|
||||
auto operator==(const ParseNodeKind& rhs) const -> bool {
|
||||
return kind == rhs.kind;
|
||||
friend auto operator==(ParseNodeKind lhs, ParseNodeKind rhs) -> bool {
|
||||
return lhs.kind == rhs.kind;
|
||||
}
|
||||
auto operator!=(const ParseNodeKind& rhs) const -> bool {
|
||||
return kind != rhs.kind;
|
||||
friend auto operator!=(ParseNodeKind lhs, ParseNodeKind rhs) -> bool {
|
||||
return lhs.kind != rhs.kind;
|
||||
}
|
||||
|
||||
// Gets a friendly name for the token for logging or debugging.
|
||||
|
||||
Reference in New Issue
Block a user